/* ====================================
   ADMIN PANEL STYLES - TIM HORTONS
   ==================================== */

:root {
    --admin-header-height: 96px;
}

/* Layout Shell */
.admin-shell {
    min-height: calc(100vh - var(--admin-header-height));
    display: flex;
    position: relative;
}

.admin-sidebar {
    width: 260px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-right: 1px solid rgba(200, 16, 46, 0.1);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 4px 0 12px rgba(200, 16, 46, 0.08);
    position: sticky;
    top: var(--admin-header-height);
    height: calc(100vh - var(--admin-header-height));
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #555;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.sidebar-link svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: rgba(200, 16, 46, 0.08);
    color: #C8102E;
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(200, 16, 46, 0.12) 0%, rgba(212, 20, 50, 0.12) 100%);
    color: #C8102E;
    font-weight: 600;
}

.sidebar-link.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #C8102E;
    padding: 1.2rem 1rem 0.4rem;
    border-top: 1px solid rgba(200, 16, 46, 0.1);
    margin-top: 0.5rem;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
}

.admin-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    border: 1px solid rgba(200, 16, 46, 0.08);
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.04);
}

/* Admin Container */
.admin-container {
    flex: 1;
    min-height: calc(100vh - var(--admin-header-height));
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* Admin Header */
.admin-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(200, 16, 46, 0.1);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.08);
    min-height: var(--admin-header-height);
}

.admin-logo-link {
    display: inline-flex;
    align-items: center;
}

.admin-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-logo {
    height: 40px;
    width: auto;
}

.admin-title {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.5rem;
    color: #C8102E;
    margin: 0;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-to-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.2);
}

.back-to-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.4);
    background: linear-gradient(135deg, #A50D25 0%, #C8102E 100%);
}

.back-to-chat-btn svg {
    width: 20px;
    height: 20px;
}

/* Stats Section */
.stats-section {
    padding: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon::before {
    content: '';
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.user-icon {
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
}

.user-icon::before {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16,17V19H2V17S2,13 9,13 16,17 16,17M12.5,7.5A3.5,3.5 0 0,1 9,11A3.5,3.5 0 0,1 5.5,7.5A3.5,3.5 0 0,1 9,4A3.5,3.5 0 0,1 12.5,7.5Z'/%3E%3C/svg%3E");
}

.conversation-icon {
    background: linear-gradient(135deg, #C8102E 0%, #A50D25 100%);
}

.conversation-icon::before {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12,3C6.5,3 2,6.58 2,11A7.13,7.13 0 0,0 2.05,11.5C2.05,13.15 3.06,15.17 4.75,16.5C4.75,17.1 4.33,18.67 2,21C4.37,20.89 6.64,20 8.47,18.5C9.61,18.83 10.81,19 12,19C17.5,19 22,15.42 22,11C22,6.58 17.5,3 12,3Z'/%3E%3C/svg%3E");
}

.inactive-icon {
    background: linear-gradient(135deg, #FFE5E5 0%, #FFD6D6 100%);
}

.inactive-icon::before {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='%23C8102E' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z'/%3E%3C/svg%3E");
}

.archived-icon {
    background: linear-gradient(135deg, #F7F7F8 0%, #E5E5EA 100%);
}

.archived-icon::before {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='%23C8102E' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3,3H21V7H3V3M4,8H20V21H4V8M9.5,11A0.5,0.5 0 0,0 9,11.5V13H15V11.5A0.5,0.5 0 0,0 14.5,11H9.5Z'/%3E%3C/svg%3E");
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 2rem;
    color: #1a1a1a;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.stat-detail {
    font-size: 0.75rem;
    color: #999;
}

.stat-detail span {
    color: #C8102E;
    font-weight: 600;
}

/* Main Content */
.admin-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 2rem;
}

/* Tabs */
.admin-tabs {
    display: none;
}

/* Panels */
.admin-panel {
    padding: 0;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .admin-sidebar {
        width: 220px;
    }
}

@media (max-width: 960px) {
    :root {
        --admin-header-height: 140px;
    }

    .admin-shell {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        position: relative;
        top: auto;
        height: auto;
        flex-direction: column;
        gap: 1.5rem;
        box-shadow: 0 4px 12px rgba(200, 16, 46, 0.12);
        overflow: visible;
    }

    .sidebar-menu {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .sidebar-link {
        flex: 1 1 calc(50% - 0.75rem);
        justify-content: center;
    }
}

@media (max-width: 600px) {
    :root {
        --admin-header-height: 180px;
    }

    .sidebar-link {
        flex: 1 1 100%;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .admin-main {
        padding: 1.5rem 0;
    }
}

.panel-header {
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.panel-title {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.35rem;
    margin: 0;
    color: #1e1e1e;
}

.panel-subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
    color: #6b6b6b;
}

.groups-header {
    align-items: flex-start;
    justify-content: space-between;
}

.groups-header .panel-actions {
    margin-left: auto;
}

.text-subtle {
    color: #9a9a9a;
}

/* Search Container */
.search-container {
    flex: 1;
    min-width: 300px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-icon {
    position: absolute;
    left: 1rem;
    width: 20px;
    height: 20px;
    color: #999;
    pointer-events: none;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem 0.75rem 3rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: white;
}

.search-input:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

.search-btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.2);
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.4);
    background: linear-gradient(135deg, #A50D25 0%, #C8102E 100%);
}

.clear-search-btn {
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-search-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.clear-search-btn svg {
    width: 20px;
    height: 20px;
}

/* Filter Container */
.filter-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #666;
}

.filter-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.panel-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 6px 16px rgba(200, 16, 46, 0.25);
}

.panel-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(200, 16, 46, 0.35);
    background: linear-gradient(135deg, #A50D25 0%, #C8102E 100%);
}

.panel-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.panel-action-btn svg {
    width: 20px;
    height: 20px;
}

/* Table Container */
.table-container {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    min-height: 400px;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(200, 16, 46, 0.2);
    border-top-color: #C8102E;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table thead {
    background: rgba(200, 16, 46, 0.05);
    border-bottom: 2px solid rgba(200, 16, 46, 0.2);
}

.admin-table th {
    padding: 1rem;
    text-align: left;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    color: #C8102E;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #333;
}

.admin-table tbody tr {
    transition: background-color 0.2s ease;
}

.admin-table tbody tr:hover {
    background: rgba(200, 16, 46, 0.03);
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.active {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.status-badge.admin {
    background: rgba(168, 85, 247, 0.1);
    color: #9333ea;
}

.status-badge.success {
    background: rgba(34, 197, 94, 0.12);
    color: #15803d;
}

.status-badge.neutral {
    background: rgba(17, 24, 39, 0.06);
    color: #374151;
}

.status-badge.archived {
    background: rgba(156, 163, 175, 0.2);
    color: #6b7280;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.admin-zones-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 240px;
}

.admin-zones-cell .status-badge {
    margin-bottom: 0.15rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.action-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.action-btn.primary {
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.2);
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.4);
    background: linear-gradient(135deg, #A50D25 0%, #C8102E 100%);
}

.action-btn.success {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.action-btn.success:hover {
    background: rgba(34, 197, 94, 0.2);
}

.action-btn.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.action-btn.view {
    background: rgba(200, 16, 46, 0.1);
    color: #C8102E;
    border: 1px solid rgba(200, 16, 46, 0.2);
}

.action-btn.view:hover {
    background: rgba(200, 16, 46, 0.2);
}

/* Empty State */
.empty-state {
    padding: 4rem 2rem;
    text-align: center;
    color: #999;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state p {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    margin: 0;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding: 1rem 0;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #C8102E;
    color: white;
    border-color: #C8102E;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: #C8102E;
    color: white;
    border-color: #C8102E;
}

.pagination-info {
    padding: 0.5rem 1rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    color: #666;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    isolation: isolate;
}

.modal.open {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 0;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    z-index: 1;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h2 {
    margin: 0;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.5rem;
    color: #1a1a1a;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.modal-close svg {
    width: 24px;
    height: 24px;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.modal-body form {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.modal-body .form-input,
.modal-body .form-textarea,
.modal-body select.form-input {
    width: 100%;
    border: 1.5px solid rgba(200, 16, 46, 0.18);
    border-radius: 10px;
    padding: 0.78rem 0.95rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.94rem;
    line-height: 1.4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    background: #fff;
    color: #1f2937;
    box-sizing: border-box;
}

.modal-body .form-input:focus,
.modal-body .form-textarea:focus,
.modal-body select.form-input:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
}

.modal-body .form-textarea {
    min-height: 90px;
    resize: vertical;
}

.modal-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.modal-form-group label {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #1a1a1a;
}

.modal-form-group input[type="email"],
.modal-form-group input[type="text"],
.modal-form-group input[type="password"],
.modal-form-group textarea,
.modal-form-group select {
    padding: 0.75rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-form-group input:focus,
.modal-form-group textarea:focus,
.modal-form-group select:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
}

.admin-zone-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.pill-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pill-checkbox input {
    accent-color: #c8102e;
}

.pill-checkbox:hover {
    border-color: #d1d5db;
    background: #ffffff;
}

.form-hint {
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.modal-help-text {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.wiki-inline-upload {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}

.wiki-inline-upload .form-input[type="file"] {
    flex: 1;
    min-width: 220px;
}

.wiki-inline-upload .wiki-file-upload-input {
    padding: 0.3rem;
    border: 1px dashed #cfd5e2;
    border-radius: 10px;
    background: #f8fafc;
    color: #374151;
}

.wiki-inline-upload .wiki-file-upload-input::file-selector-button {
    margin-right: 0.75rem;
    border: 0;
    border-radius: 8px;
    padding: 0.45rem 0.8rem;
    background: linear-gradient(135deg, #d2143a 0%, #c8102e 100%);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.wiki-inline-upload .wiki-file-upload-input:hover {
    border-color: #c8102e;
    background: #fff7f8;
}

.space-access-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.35rem;
}

.toggle-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: #444;
    cursor: pointer;
    margin-bottom: 1rem;
}

.toggle-input input {
    width: 18px;
    height: 18px;
    accent-color: #C8102E;
}

.modal-primary-btn,
.modal-secondary-btn {
    padding: 0.75rem 1.75rem;
    border-radius: 10px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-primary-btn {
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: #fff;
    box-shadow: 0 6px 16px rgba(200, 16, 46, 0.25);
}

.modal-primary-btn:hover,
.modal-primary-btn:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(200, 16, 46, 0.35);
    background: linear-gradient(135deg, #A50D25 0%, #C8102E 100%);
}

.modal-secondary-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

.modal-secondary-btn:hover,
.modal-secondary-btn:focus-visible {
    background: rgba(0, 0, 0, 0.1);
}

.modal-primary-btn:disabled,
.modal-secondary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Conversation Detail */
.conversation-info {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(200, 16, 46, 0.05);
    border-radius: 12px;
}

.conversation-info h3 {
    margin: 0 0 1rem 0;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.25rem;
    color: #1a1a1a;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #333;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 8px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.message-role {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
}

.message-role.user {
    color: #C8102E;
}

.message-role.assistant {
    color: #A50D25;
}

.message-time {
    font-size: 0.75rem;
    color: #999;
}

.message-item .message-content {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #333;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Wiki Management */
.wiki-admin-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    padding: 0;
}

.wiki-admin-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.wiki-admin-column.details {
    min-height: 100%;
}

.wiki-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.wiki-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    justify-content: flex-end;
}

.wiki-section-header h2,
.wiki-section-header h3,
.wiki-section-header h4 {
    margin: 0;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #1e1e1e;
}

.wiki-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.wiki-space-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(200, 16, 46, 0.12);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.wiki-space-card:hover {
    border-color: rgba(200, 16, 46, 0.4);
    box-shadow: 0 8px 20px rgba(200, 16, 46, 0.08);
}

.wiki-space-card.active {
    border-color: #C8102E;
    box-shadow: 0 10px 26px rgba(200, 16, 46, 0.16);
}

.wiki-space-card .space-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wiki-space-card .space-icon {
    font-size: 1.6rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wiki-space-card .space-icon i,
.wiki-space-card .space-icon svg {
    width: 24px;
    height: 24px;
    color: #C8102E;
    stroke-width: 2;
}

.wiki-space-card .space-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
}

.wiki-space-card .space-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a1a1a;
}

.wiki-space-card .space-slug {
    font-size: 0.75rem;
    color: #888;
    letter-spacing: 0.02em;
}

.wiki-space-card .space-counts {
    margin-left: auto;
    font-size: 0.8rem;
    color: #444;
    background: rgba(200, 16, 46, 0.08);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.wiki-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 0.35rem;
}

.wiki-form-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-label {
    display: block;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}

.form-label.required::after {
    content: ' *';
    color: #C8102E;
}

.wiki-form-card h3,
.wiki-form-card h4 {
    margin: 0;
    color: #1a1a1a;
}

.wiki-form-card .form-input,
.wiki-form-card .form-textarea,
.wiki-form-card select {
    width: 100%;
    border: 2px solid rgba(200, 16, 46, 0.15);
    border-radius: 10px;
    padding: 0.875rem 1rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a1a;
}

.wiki-form-card .form-input::placeholder,
.wiki-form-card .form-textarea::placeholder {
    color: #999;
}

.wiki-form-card .form-input:hover,
.wiki-form-card .form-textarea:hover,
.wiki-form-card select:hover {
    border-color: rgba(200, 16, 46, 0.3);
}

.wiki-form-card .form-input:focus,
.wiki-form-card .form-textarea:focus,
.wiki-form-card select:focus {
    border-color: #C8102E;
    box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.12);
    outline: none;
    background: #fff;
}

.wiki-form-card .form-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.wiki-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    border: none;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(200, 16, 46, 0.08);
    color: #C8102E;
}

.wiki-btn.primary {
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(200, 16, 46, 0.2);
}

.wiki-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(200, 16, 46, 0.3);
}

.wiki-btn.full {
    width: 100%;
}

/* Rich Text Editor */
.rich-editor {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    overflow: hidden;
}

.rich-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(200, 16, 46, 0.03);
    border-bottom: 1px solid rgba(200, 16, 46, 0.08);
}

.rich-editor-upload-status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    align-self: flex-start;
    margin: -0.2rem 1rem 0;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    color: #9b0f27;
    background: rgba(200, 16, 46, 0.1);
}

.rich-editor-btn {
    border: none;
    background: rgba(255, 255, 255, 0.9);
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    color: #444;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    user-select: none;
}

.rich-editor-btn:hover,
.rich-editor-btn:focus-visible {
    background: rgba(200, 16, 46, 0.12);
    color: #C8102E;
    outline: none;
}

.rich-editor-btn.active {
    background: rgba(200, 16, 46, 0.18);
    color: #9b0f27;
    box-shadow: inset 0 0 0 1px rgba(200, 16, 46, 0.22);
}

.rich-editor-divider {
    width: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 0.25rem;
    align-self: stretch;
}

.rich-editor-btn .underline {
    text-decoration: underline;
}

.rich-editor-content {
    min-height: 240px;
    max-height: 480px;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #1a1a1a;
}

.rich-editor-content:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(200, 16, 46, 0.2);
}

.rich-editor-content:empty::before {
    content: attr(data-placeholder);
    color: #aaa;
    pointer-events: none;
}

.rich-editor-content a {
    color: #C8102E;
    text-decoration: underline;
}

.rich-editor-content > :first-child {
    margin-top: 0;
}

.rich-editor-content > :last-child {
    margin-bottom: 0;
}

.rich-editor-content h1,
.rich-editor-content h2,
.rich-editor-content h3,
.rich-editor-content h4,
.rich-editor-content h5,
.rich-editor-content h6 {
    margin: 1.1em 0 0.45em;
    line-height: 1.25;
    color: #1F1F24;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
}

.rich-editor-content h1 { font-size: 2.25rem; letter-spacing: -0.022em; }
.rich-editor-content h2 { font-size: 1.9rem; letter-spacing: -0.018em; }
.rich-editor-content h3 { font-size: 1.55rem; letter-spacing: -0.012em; }
.rich-editor-content h4 { font-size: 1.3rem; }
.rich-editor-content h5 { font-size: 1.12rem; color: #2A2A31; }
.rich-editor-content h6 {
    font-size: 1rem;
    color: #5A5A62;
    letter-spacing: 0.01em;
}

.rich-editor-content p {
    margin: 0 0 0.55rem;
}

.rich-editor-content ul,
.rich-editor-content ol {
    margin: 0 0 0.6rem;
    padding-left: 1.3rem;
}

.rich-editor-content li + li {
    margin-top: 0.18rem;
}

.rich-editor-content blockquote {
    margin: 0.8rem 0;
    padding: 0.25rem 0 0.25rem 0.8rem;
    border-left: 3px solid rgba(200, 16, 46, 0.35);
    color: #5F5F67;
}

.rich-editor-content pre {
    margin: 0.8rem 0;
    padding: 0.8rem 0.9rem;
    border-radius: 8px;
    background: #111216;
    color: #F4F4F8;
    overflow-x: auto;
}

.rich-editor-content code {
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.rich-editor-content figure {
    margin: 0.75rem 0;
}

.rich-editor-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0.75rem 0;
    cursor: pointer;
    transition: box-shadow 0.18s ease, outline-color 0.18s ease;
}

.rich-editor-content img.rich-editor-image-selected {
    outline: 2px solid rgba(200, 16, 46, 0.55);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.12);
}

.rich-editor-image-resize {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.32rem 0.5rem;
    border-radius: 8px;
    border: 1px solid rgba(200, 16, 46, 0.16);
    background: rgba(255, 255, 255, 0.92);
}

.rich-editor-image-resize-label {
    font-size: 0.75rem;
    color: #7a7a82;
    font-weight: 600;
}

.rich-editor-image-resize-range {
    width: 110px;
    accent-color: #C8102E;
}

.rich-editor-image-resize-value {
    min-width: 2.55rem;
    text-align: right;
    font-size: 0.75rem;
    color: #2f2f35;
    font-variant-numeric: tabular-nums;
}

.rich-editor-image-resize-preset {
    padding: 0.32rem 0.5rem;
    font-size: 0.75rem;
}

.rich-editor-image-align {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.15rem;
}

.rich-editor-image-align-btn {
    padding: 0.32rem 0.5rem;
    font-size: 0.75rem;
}

.rich-editor-content iframe {
    max-width: 100%;
    border: none;
}

.rich-editor-video {
    position: relative;
    padding-bottom: 56.25%;
    margin: 1rem 0;
}

.rich-editor-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.rich-editor-hidden-input {
    display: none;
}

.rich-editor-select {
    border: none;
    background: rgba(255, 255, 255, 0.9);
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.82rem;
    color: #444;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    padding-right: 1.4rem;
}
.rich-editor-select:hover,
.rich-editor-select:focus-visible {
    background-color: rgba(200, 16, 46, 0.12);
    color: #C8102E;
}

.rich-editor-color-wrapper {
    position: relative;
    display: inline-flex;
}

.rich-editor-color-icon {
    font-weight: 700;
    font-size: 0.9rem;
    background: linear-gradient(135deg, #C8102E, #e67e22, #1a73e8, #0d904f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.rich-editor-color-background-icon {
    font-weight: 700;
    font-size: 0.92rem;
    color: #444;
}

.rich-editor-color-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 0.6rem 0.65rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    min-width: 240px;
    max-height: 320px;
    overflow-y: auto;
}

.rich-editor-color-group + .rich-editor-color-group {
    margin-top: 0.45rem;
    padding-top: 0.45rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.rich-editor-color-group-title {
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #7f7f87;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.rich-editor-color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
}

.rich-editor-color-swatch {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    padding: 0;
}
.rich-editor-color-swatch:hover {
    transform: scale(1.08);
    border-color: rgba(0, 0, 0, 0.35);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.rich-editor-upload-btn {
    position: relative;
}

.rich-editor-upload-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(200, 16, 46, 0.2);
    border-top-color: #C8102E;
    border-radius: 50%;
    animation: re-spin 0.6s linear infinite;
}

@keyframes re-spin {
    to { transform: rotate(360deg); }
}

/* Image Library Modal */
.rich-editor-image-modal {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.rich-editor-image-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 20, 30, 0.48);
    backdrop-filter: blur(2px);
}

.rich-editor-image-modal-content {
    position: relative;
    z-index: 1;
    width: min(1100px, 96vw);
    max-height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 28px 64px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
}

.rich-editor-image-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    background: linear-gradient(180deg, rgba(200, 16, 46, 0.05), rgba(200, 16, 46, 0.01));
}

.rich-editor-image-modal-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #1b1b1f;
}

.rich-editor-image-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.06);
    color: #333;
    font-size: 0.82rem;
}

.rich-editor-image-close:hover {
    background: rgba(200, 16, 46, 0.12);
    color: #C8102E;
}

.rich-editor-image-modal-body {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 420px;
    max-height: calc(90vh - 68px);
}

.rich-editor-image-sidebar {
    border-right: 1px solid rgba(0, 0, 0, 0.07);
    background: #fcfcfd;
    overflow-y: auto;
    padding: 0.55rem;
}

.rich-editor-folder-btn {
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    padding: 0.42rem 0.6rem;
    color: #3f3f45;
    cursor: pointer;
    font-size: 0.82rem;
    margin-bottom: 0.15rem;
}

.rich-editor-folder-btn:hover {
    background: rgba(200, 16, 46, 0.08);
    color: #8b0d26;
}

.rich-editor-folder-btn.active {
    border-color: rgba(200, 16, 46, 0.2);
    background: rgba(200, 16, 46, 0.13);
    color: #7f0d24;
    font-weight: 600;
}

.rich-editor-folder-loading {
    font-size: 0.75rem;
    color: #888;
    padding: 0.35rem 0.6rem 0.6rem;
}

.rich-editor-image-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.rich-editor-image-main-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.rich-editor-image-search {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 8px;
    padding: 0.48rem 0.62rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.83rem;
    color: #34343a;
    background: #fff;
}

.rich-editor-image-search:focus {
    outline: none;
    border-color: rgba(200, 16, 46, 0.35);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
}

.rich-editor-image-count {
    color: #6f6f76;
    font-size: 0.78rem;
    white-space: nowrap;
}

.rich-editor-image-preview {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: #fcfcfd;
    padding: 0.8rem 1rem;
}

.rich-editor-image-preview-frame {
    height: 180px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rich-editor-image-preview-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.rich-editor-image-preview-meta {
    margin-top: 0.55rem;
    font-size: 0.83rem;
    color: #2f2f35;
}

.rich-editor-image-preview-actions {
    margin-top: 0.6rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.rich-editor-image-grid {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0.9rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 0.75rem;
}

.rich-editor-image-card {
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 10px;
    background: #fff;
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    cursor: pointer;
    text-align: left;
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.rich-editor-image-card:hover {
    transform: translateY(-2px);
    border-color: rgba(200, 16, 46, 0.28);
    box-shadow: 0 8px 18px rgba(200, 16, 46, 0.11);
}

.rich-editor-image-card.selected {
    border-color: rgba(200, 16, 46, 0.45);
    box-shadow: 0 0 0 2px rgba(200, 16, 46, 0.14);
}

.rich-editor-image-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    background: #f7f7f8;
}

.rich-editor-image-card span {
    font-size: 0.73rem;
    color: #4c4c54;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rich-editor-image-empty {
    padding: 1.25rem 1rem;
    color: #8c8c93;
    font-size: 0.84rem;
}

@media (max-width: 920px) {
    .rich-editor-image-modal-body {
        grid-template-columns: 1fr;
        max-height: calc(90vh - 68px);
    }

    .rich-editor-image-sidebar {
        max-height: 140px;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    }

    .rich-editor-image-preview-frame {
        height: 140px;
    }
}

/* ── Emoji Picker ── */

.rich-editor-emoji-wrapper {
    position: relative;
    display: inline-flex;
}

.rich-editor-emoji-btn {
    font-size: 1rem;
    line-height: 1;
}

.rich-editor-emoji-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 60;
    width: 320px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    animation: emojiDropIn 0.18s ease-out;
}

@keyframes emojiDropIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.rich-editor-emoji-search-wrap {
    position: relative;
    padding: 0.6rem 0.65rem 0.45rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(200, 16, 46, 0.02);
}

.rich-editor-emoji-search {
    width: 100%;
    padding: 0.45rem 2rem 0.45rem 0.7rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 9px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.82rem;
    color: #333;
    background: #fff;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.rich-editor-emoji-search:focus {
    border-color: rgba(200, 16, 46, 0.35);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
}

.rich-editor-emoji-search::placeholder {
    color: #aaa;
}

.rich-editor-emoji-search-clear {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: #888;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.65rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 1;
}

.rich-editor-emoji-search-clear:hover {
    background: rgba(200, 16, 46, 0.12);
    color: #C8102E;
}

.rich-editor-emoji-scroll {
    max-height: 280px;
    overflow-y: auto;
    padding: 0.35rem 0.5rem 0.5rem;
    scroll-behavior: smooth;
}

.rich-editor-emoji-scroll::-webkit-scrollbar {
    width: 5px;
}

.rich-editor-emoji-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.rich-editor-emoji-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 10px;
}

.rich-editor-emoji-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.22);
}

.rich-editor-emoji-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: #aaa;
    font-size: 0.82rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
}

.rich-editor-emoji-category {
    margin-bottom: 0.35rem;
}

.rich-editor-emoji-category-header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.25rem 0.25rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
}

.rich-editor-emoji-category-header span {
    font-size: 0.85rem;
}

.rich-editor-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.rich-editor-emoji-item {
    border: none;
    background: transparent;
    font-size: 1.35rem;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s ease;
    padding: 0;
    line-height: 1;
}

.rich-editor-emoji-item:hover {
    background: rgba(200, 16, 46, 0.08);
    transform: scale(1.2);
}

.rich-editor-emoji-item:active {
    transform: scale(0.95);
    background: rgba(200, 16, 46, 0.15);
}

@media (max-width: 480px) {
    .rich-editor-emoji-dropdown {
        width: 280px;
        right: -1rem;
    }
    .rich-editor-emoji-grid {
        grid-template-columns: repeat(7, 1fr);
    }
    .rich-editor-emoji-item {
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
    }
}

.wiki-section {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.wiki-section-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.wiki-table-wrapper {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
}

.wiki-table {
    width: 100%;
    border-collapse: collapse;
}

.wiki-table th,
.wiki-table td {
    padding: 0.9rem;
    text-align: left;
    font-size: 0.85rem;
}

.wiki-table th {
    background: rgba(0, 0, 0, 0.03);
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.78rem;
}

.wiki-table tbody tr {
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.wiki-table tbody tr:hover {
    background: rgba(200, 16, 46, 0.04);
}

.wiki-table td .table-actions {
    display: flex;
    gap: 0.5rem;
}

.category-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: calc(var(--depth, 0) * 1.5rem);
    font-weight: 600;
}

.category-name[data-depth="0"] {
    margin-left: 0;
}

.category-type {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.category-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.category-type-badge.root {
    background: rgba(33, 150, 243, 0.12);
    color: #0b5394;
}

.category-type-badge.sub {
    background: rgba(156, 39, 176, 0.12);
    color: #6a1b9a;
}

.category-parent-label {
    font-size: 0.75rem;
    color: #6b7280;
}

.wiki-table .status-badge {
    font-size: 0.7rem;
    padding: 0.35rem 0.65rem;
}

.wiki-selected-space {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wiki-selected-space h3 {
    margin: 0;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #1e1e1e;
}

.wiki-selected-space p {
    margin: 0;
    font-size: 0.9rem;
    color: #555;
}

.mini-btn {
    background: rgba(200, 16, 46, 0.08);
    border: none;
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.mini-btn:hover {
    background: rgba(200, 16, 46, 0.18);
}

.mini-btn svg {
    width: 18px;
    height: 18px;
    color: #C8102E;
}

.modal-content.small {
    max-width: 560px;
}

.modal-content.medium {
    max-width: 720px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.modal-subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.95rem;
    color: #7a7a7a;
}

.group-members-content {
    margin-bottom: 1.5rem;
}

.group-members-loading,
.group-members-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    text-align: center;
    color: #666;
}

.group-members-loading .loading-spinner {
    width: 36px;
    height: 36px;
}

.group-members-empty svg {
    width: 56px;
    height: 56px;
    color: rgba(200, 16, 46, 0.45);
}

.group-members-empty p {
    margin: 0;
    font-size: 0.95rem;
}

.group-members-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.group-member-item {
    padding: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.group-member-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.group-member-name {
    font-weight: 600;
    color: #2c2c2c;
}

.group-member-email {
    font-size: 0.95rem;
    color: #6b6b6b;
}

.group-member-date {
    font-size: 0.85rem;
    color: #9a9a9a;
}

.group-add-form .modal-actions {
    justify-content: flex-start;
    border: none;
    padding-top: 0.25rem;
}

.group-add-form .modal-primary-btn {
    align-self: flex-start;
}

.mini-btn.danger {
    background: rgba(200, 16, 46, 0.12);
    color: #C8102E;
}

.mini-btn.danger:hover {
    background: rgba(200, 16, 46, 0.22);
}

.mini-btn.danger svg {
    color: inherit;
}

/* Icon Picker Styles */
.icon-picker-wrapper {
    position: relative;
}

.icon-picker-input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.icon-preview {
    width: 48px;
    height: 48px;
    border: 2px solid rgba(200, 16, 46, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.icon-preview:hover {
    border-color: rgba(200, 16, 46, 0.4);
    background: rgba(200, 16, 46, 0.05);
}

.icon-preview i,
.icon-preview svg {
    width: 24px;
    height: 24px;
    color: #C8102E;
    stroke-width: 2;
}

.icon-preview.empty {
    color: #999;
    font-size: 0.75rem;
    text-align: center;
    line-height: 1.2;
}

.icon-picker-trigger {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    border: 2px solid rgba(200, 16, 46, 0.15);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #666;
}

.icon-picker-trigger:hover {
    border-color: rgba(200, 16, 46, 0.3);
    background: rgba(200, 16, 46, 0.02);
}

.icon-picker-trigger i {
    margin-left: auto;
    width: 16px;
    height: 16px;
}

.icon-picker-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid rgba(200, 16, 46, 0.15);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.icon-search-input {
    padding: 0.875rem 1rem;
    border: none;
    border-bottom: 1px solid rgba(200, 16, 46, 0.1);
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    outline: none;
}

.icon-search-input:focus {
    background: rgba(200, 16, 46, 0.02);
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 0.5rem;
    padding: 1rem;
    overflow-y: auto;
    max-height: 320px;
}

.icon-option {
    width: 56px;
    height: 56px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.icon-option:hover {
    border-color: rgba(200, 16, 46, 0.4);
    background: rgba(200, 16, 46, 0.05);
    transform: scale(1.05);
}

.icon-option.selected {
    border-color: #C8102E;
    background: rgba(200, 16, 46, 0.1);
}

.icon-option i,
.icon-option svg {
    width: 24px;
    height: 24px;
    color: #444;
    stroke-width: 2;
}

.icon-option:hover i,
.icon-option:hover svg,
.icon-option.selected i,
.icon-option.selected svg {
    color: #C8102E;
}

.icon-picker-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: #999;
    font-size: 0.875rem;
}

.empty-state.small {
    padding: 1.5rem;
    font-size: 0.85rem;
}

.empty-state.small p {
    margin: 0;
}

.wiki-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.78rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    letter-spacing: 0.01em;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.85);
    color: #444;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(6px);
}

.wiki-action-btn:hover,
.wiki-action-btn:focus-visible {
    transform: translateY(-1px);
    outline: none;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.wiki-action-btn.primary {
    background: linear-gradient(135deg, rgba(200, 16, 46, 0.85) 0%, rgba(212, 20, 50, 0.95) 100%);
    border-color: rgba(200, 16, 46, 0.25);
    color: #fff;
}

.wiki-action-btn.primary:hover,
.wiki-action-btn.primary:focus-visible {
    background: linear-gradient(135deg, rgba(200, 16, 46, 0.95) 0%, rgba(166, 13, 37, 0.95) 100%);
}

.wiki-action-btn.danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.16) 0%, rgba(220, 38, 38, 0.24) 100%);
    border-color: rgba(220, 38, 38, 0.25);
    color: #b91c1c;
}

.wiki-action-btn.danger:hover,
.wiki-action-btn.danger:focus-visible {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.22) 0%, rgba(220, 38, 38, 0.32) 100%);
    color: #991b1b;
}

.wiki-action-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.wiki-table .wiki-action-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.72rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

/* Responsive */
@media (max-width: 768px) {
    .admin-header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .admin-title {
        font-size: 1.25rem;
    }

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

    .admin-panel {
        padding: 0 1rem;
    }

    .panel-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-container {
        min-width: 100%;
    }

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

    .admin-table {
        min-width: 800px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .wiki-admin-grid {
        grid-template-columns: 1fr;
        padding: 0;
    }

    .wiki-admin-column {
        gap: 1rem;
    }

    .wiki-section {
        padding: 1.25rem;
    }

    .wiki-table {
        min-width: 700px;
    }
}

.admin-body {
    overflow: auto;
}

.space-meta {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #555;
}

.space-meta span strong {
    color: #1a1a1a;
    font-weight: 600;
}

/* Metadata upload rows */
.metadata-row {
    flex-wrap: wrap;
}

.meta-value-wrapper .meta-upload-btn {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .meta-value-wrapper {
        flex-wrap: wrap;
    }

    .meta-value-wrapper .meta-upload-btn {
        width: 100%;
    }
}

/* ========== Agente (RAG) redesign - Jonathan Ive Style ========== */
/* Minimalismo, claridad y enfoque en el contenido */

.agent-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 0 1.5rem 0;
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 0;
}

.agent-hero div:first-child {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-hero h2 {
    font-family: 'Sofia Pro', -apple-system, sans-serif;
    font-weight: 600;
    font-size: 32px;
    letter-spacing: -0.02em;
    color: #111;
    margin: 0;
}

.agent-eyebrow {
    font-family: 'Sofia Pro', -apple-system, sans-serif;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #888;
    font-weight: 600;
    margin: 0;
}

.agent-subtitle {
    font-family: 'Sofia Pro', -apple-system, sans-serif;
    font-size: 15px;
    color: #666;
    margin: 0;
    max-width: 600px;
    line-height: 1.5;
}

.agent-hero-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.agent-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 400px;
    background: #FAFAFA;
    border-radius: 12px;
    margin-top: 1.5rem;
    overflow: hidden;
}

/* Sidebar estilo Apple Mail / Settings */
.agent-sidebar {
    background: #F2F2F7;
    /* Gris sistema */
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
}

.agent-sidebar-header {
    padding: 0 12px 16px 12px;
}

.agent-sidebar-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.agent-store-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Items de la lista de stores — scoped to agent panel */
.agent-sidebar .wiki-space-card {
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    box-shadow: none;
}

.agent-sidebar .wiki-space-card:hover {
    background: rgba(0, 0, 0, 0.04);
    box-shadow: none;
    border-color: transparent;
}

.agent-sidebar .wiki-space-card.active {
    background: #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-color: transparent;
}

.agent-sidebar .wiki-space-card.active::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    height: 16px;
    width: 3px;
    background: #C8102E;
    border-radius: 2px;
}

.agent-sidebar .wiki-space-card .space-icon {
    font-size: 1.2rem;
    color: #555;
    background: transparent;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agent-sidebar .wiki-space-card.active .space-icon {
    color: #C8102E;
}

.agent-sidebar .wiki-space-card .space-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agent-sidebar .wiki-space-card .space-name {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
}

.agent-sidebar .wiki-space-card .space-slug {
    display: none;
}

.agent-sidebar .wiki-space-card .space-counts {
    background: transparent;
    color: #999;
    font-size: 12px;
    padding: 0;
    font-weight: 400;
}

/* Área Principal */
.agent-main {
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1200px;
    width: 100%;
}

.agent-card {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
    padding: 24px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.agent-card:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

.agent-card-header h4 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #111;
}

.agent-card-header .agent-eyebrow {
    margin-bottom: 4px;
}

.agent-grid {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 24px;
}

/* Tabla de archivos rediseñada — scoped to agent panel */
.agent-main .wiki-table-wrapper {
    border: none;
    background: transparent;
    border-radius: 0;
}

.agent-main .wiki-table {
    border-collapse: separate;
    border-spacing: 0;
}

.agent-main .wiki-table th {
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    color: #888;
    font-weight: 600;
    font-size: 11px;
    padding: 12px 16px;
}

.agent-main .wiki-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 14px;
    color: #333;
}

.agent-main .wiki-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.015);
}

.agent-main .wiki-table tbody tr:last-child td {
    border-bottom: none;
}

.agent-toggle {
    display: inline-flex;
    background: #F0F0F3;
    border-radius: 999px;
    padding: 4px;
    gap: 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.pill-tab {
    border: none;
    background: transparent;
    border-radius: 999px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #555;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pill-tab.active {
    background: #FFFFFF;
    color: #111;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.pill-tab:hover {
    color: #111;
}

.agent-doc-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 24px 0 0 0;
}

/* ===== IMAGE LIBRARY ADMIN ===== */

/* Tab switcher */
.img-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-100);
    margin-bottom: 1.25rem;
}

.img-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
}

.img-tab svg {
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.img-tab:hover {
    color: var(--gray-700);
}

.img-tab:hover svg {
    opacity: 0.7;
}

.img-tab.active {
    color: #C8102E;
    font-weight: 600;
    border-bottom-color: #C8102E;
}

.img-tab.active svg {
    opacity: 1;
    color: #C8102E;
}

.img-admin-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    min-height: 560px;
    position: relative;
}

/* ── Sidebar ── */
.img-admin-sidebar {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    height: fit-content;
    position: sticky;
    top: 120px;
}

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

.img-sidebar-title {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
}

.img-new-folder-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    background: #fff;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s ease;
}

.img-new-folder-btn:hover {
    border-color: #C8102E;
    color: #C8102E;
    background: rgba(200, 16, 46, 0.04);
}

/* Folder tree */
.img-folder-tree {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 480px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
}

.img-folder-node {
    display: flex;
    align-items: center;
}

.img-folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--gray-700);
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.img-folder-item:hover {
    background: rgba(200, 16, 46, 0.04);
    color: var(--gray-900);
}

.img-folder-item.active {
    background: rgba(200, 16, 46, 0.08);
    color: #C8102E;
    font-weight: 600;
}

.img-folder-item > svg {
    flex-shrink: 0;
    opacity: 0.35;
}

.img-folder-item.active > svg {
    opacity: 0.8;
    color: #C8102E;
}

/* Chevron for collapsible folders */
.img-folder-chevron {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    transition: transform 0.2s ease, color 0.15s ease;
    flex-shrink: 0;
    border-radius: 4px;
    padding: 0;
}

.img-folder-chevron:hover {
    color: var(--gray-600);
}

.img-folder-chevron.expanded {
    transform: rotate(90deg);
}

.img-folder-chevron-spacer {
    width: 20px;
    flex-shrink: 0;
}

.img-folder-count {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 100px;
    min-width: 22px;
    text-align: center;
    line-height: 1.4;
}

.img-folder-item.active .img-folder-count {
    background: rgba(200, 16, 46, 0.12);
    color: #C8102E;
}

/* Delete folder button */
.img-folder-delete {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0;
}

.img-folder-node:hover .img-folder-delete {
    opacity: 1;
}

.img-folder-delete:hover {
    background: rgba(200, 16, 46, 0.08);
    color: #C8102E;
}

.img-loading-text {
    font-size: 0.85rem;
    color: var(--gray-500);
    padding: 12px 14px;
    margin: 0;
}

/* ── Inputs ── */
.img-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    color: var(--gray-900);
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    box-sizing: border-box;
}

.img-input:focus {
    border-color: rgba(200, 16, 46, 0.4);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.07);
}

.img-input::placeholder {
    color: var(--gray-400);
}

/* ── Main content area ── */
.img-admin-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.img-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.img-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.img-toolbar-left > svg {
    color: var(--gray-400);
    flex-shrink: 0;
}

.img-current-folder {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.img-total-count {
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: 500;
    padding: 3px 10px;
    background: var(--gray-100);
    border-radius: 100px;
}

.img-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Search */
.img-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--gray-100);
    border: 1.5px solid transparent;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.img-search:focus-within {
    background: #fff;
    border-color: var(--gray-200);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.03);
}

.img-search svg {
    flex-shrink: 0;
    color: var(--gray-400);
}

.img-search input {
    border: none;
    background: transparent;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    color: var(--gray-900);
    outline: none;
    width: 160px;
}

.img-search input::placeholder {
    color: var(--gray-400);
}

/* Upload area */
.img-upload-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.img-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    background: #fff;
    border: 1.5px dashed var(--gray-300);
    border-radius: 10px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.84rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 200px;
    white-space: nowrap;
}

.img-upload-label span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.img-upload-label:hover {
    border-color: #C8102E;
    color: #C8102E;
    background: rgba(200, 16, 46, 0.03);
}

.img-upload-label.has-file {
    border-style: solid;
    border-color: rgba(200, 16, 46, 0.25);
    color: var(--gray-800);
    font-weight: 500;
    background: rgba(200, 16, 46, 0.03);
}

.img-upload-label input[type="file"] {
    display: none;
}

.img-upload-label svg {
    flex-shrink: 0;
}

.img-btn-upload {
    padding: 8px 20px;
    border: none;
    border-radius: 10px;
    background: #C8102E;
    color: #fff;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.img-btn-upload:hover {
    background: #A50D25;
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.25);
}

.img-btn-upload:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

/* ── Image Grid ── */
.img-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
}

.img-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.img-card:hover {
    box-shadow: 0 10px 30px rgba(200, 16, 46, 0.08), 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.img-card-thumb {
    position: relative;
    width: 100%;
    height: 170px;
    overflow: hidden;
    background: var(--gray-100);
    cursor: zoom-in;
}

.img-card-thumb:focus-visible {
    outline: 3px solid rgba(200, 16, 46, 0.45);
    outline-offset: -3px;
}

.img-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.img-card:hover .img-card-thumb img {
    transform: scale(1.04);
}

.img-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.55) 100%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    padding-bottom: 12px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.img-card:hover .img-card-overlay {
    opacity: 1;
}

.img-card-overlay button {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--gray-800);
    cursor: pointer;
    transition: all 0.15s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: relative;
}

.img-card-overlay button:hover {
    background: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.img-card-overlay button.danger:hover {
    background: #C8102E;
    color: #fff;
}

.img-card-overlay button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

/* ── Card info ── */
.img-card-info {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.img-card-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.3;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.img-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.img-badge {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(200, 16, 46, 0.07);
    color: #C8102E;
}

.img-size {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ── Rename form ── */
.img-rename-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.img-rename-actions {
    display: flex;
    gap: 6px;
}

.img-btn-save {
    flex: 1;
    padding: 7px 12px;
    border: none;
    border-radius: 8px;
    background: #C8102E;
    color: #fff;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.img-btn-save:hover {
    background: #A50D25;
}

.img-btn-save:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.img-btn-cancel {
    flex: 1;
    padding: 7px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: #fff;
    color: var(--gray-700);
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.img-btn-cancel:hover {
    background: var(--gray-100);
}

/* ── Empty state ── */
.img-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
}

.img-empty-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: var(--gray-100);
    color: var(--gray-300);
    margin-bottom: 16px;
}

.img-empty p {
    font-size: 0.9rem;
    color: var(--gray-500);
    margin: 0;
    line-height: 1.4;
}

/* ── Loading state ── */
.img-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    gap: 12px;
}

.img-loading p {
    font-size: 0.88rem;
    color: var(--gray-500);
    margin: 0;
}

/* ── Modal ── */
.img-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: imgFadeIn 0.15s ease;
}

@keyframes imgFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.img-modal {
    background: #fff;
    border-radius: 18px;
    width: 420px;
    max-width: 92vw;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18), 0 8px 20px rgba(0, 0, 0, 0.08);
    animation: imgModalIn 0.2s ease;
    overflow: hidden;
}

@keyframes imgModalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.img-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.img-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gray-900);
}

.img-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.15s ease;
}

.img-modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.img-modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.img-modal-field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.img-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.015);
}

/* ── Tooltips ── */
.img-card-overlay [data-tooltip],
.img-folder-delete[data-tooltip],
.img-new-folder-btn[data-tooltip] {
    position: relative;
}

.img-card-overlay [data-tooltip]::after,
.img-folder-delete[data-tooltip]::after,
.img-new-folder-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    background: var(--gray-900);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 10;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
}

.img-card-overlay [data-tooltip]:hover::after,
.img-folder-delete[data-tooltip]:hover::after,
.img-new-folder-btn[data-tooltip]:hover::after {
    opacity: 1;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .img-admin-layout {
        grid-template-columns: 1fr;
    }
    .img-admin-sidebar {
        order: 2;
        position: static;
    }
    .img-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .img-toolbar-right {
        flex-wrap: wrap;
    }
    .img-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    .img-search input {
        width: 100%;
    }
}

.wiki-btn.ghost {
    background: #f6f6f6;
    color: #333;
    border-radius: 100px;
    padding: 10px 18px;
    border: 1px solid rgba(0, 0, 0, 0.07);
}

.wiki-btn.ghost:hover {
    background: #e9e9e9;
}

.wiki-btn.ghost.danger {
    color: #b3261e;
    border-color: rgba(179, 38, 30, 0.2);
}

.wiki-btn.ghost.danger:hover {
    background: #fdebea;
}

.image-preview-modal .modal-body {
    gap: 12px;
}

.image-preview-body {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.image-preview-frame {
    background: #f3f4f6;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
}

.image-preview-frame img {
    max-width: 100%;
    max-height: 420px;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.link-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.link-row .form-input {
    flex: 1;
}

.image-preview-actions {
    margin-top: 1rem;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Formulario de subida — scoped to agent panel */
.agent-upload-form .form-group {
    margin-bottom: 16px;
}

.agent-main .form-label {
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
}

.agent-main .form-input,
.agent-main .form-textarea,
.agent-main select {
    border: 1px solid #E5E5E5;
    background: #FAFAFA;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.agent-main .form-input:focus,
.agent-main .form-textarea:focus,
.agent-main select:focus {
    background: #FFFFFF;
    border-color: #C8102E;
    box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.05);
}

/* Metadatos */
.metadata-section {
    background: #FAFAFA;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(0, 0, 0, 0.03);
    margin-bottom: 16px;
}

.metadata-header {
    margin-bottom: 12px;
}

.metadata-row {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
}

/* Botones refinados — scoped to agent panel */
.agent-main .wiki-btn.primary {
    background: #111;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 100px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
}

.agent-main .wiki-btn.primary:hover {
    background: #333;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* mini-btn override — scoped to agent panel */
.agent-main .mini-btn {
    border-radius: 8px;
    font-size: 13px;
    color: #555;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.agent-main .mini-btn:hover {
    background: #F5F5F5;
    color: #111;
}

/* Estados vacíos — scoped to agent panel */
.agent-main .empty-state.small {
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
    font-style: italic;
}

@media (max-width: 1100px) {
    .agent-layout {
        grid-template-columns: 1fr;
    }

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

    .agent-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .agent-hero-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .agent-images-layout {
        grid-template-columns: 1fr;
    }

    .image-preview-body {
        grid-template-columns: 1fr;
    }

    .image-library-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ====================================
   ANALYTICS DASHBOARD STYLES
   ==================================== */

.analytics-section {
    margin-top: 2rem;
    padding: 0;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.analytics-title-group {
    flex: 1;
    min-width: 200px;
}

.analytics-title {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.5rem;
    color: #1a1a1a;
    margin: 0 0 0.25rem;
}

.analytics-subtitle {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #666;
    margin: 0;
}

.analytics-filters {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.analytics-filters .filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analytics-filters label {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    color: #666;
    white-space: nowrap;
}

.analytics-select {
    padding: 0.625rem 2rem 0.625rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    color: #333;
    background-color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 20px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: all 0.2s ease;
}

.analytics-select:hover {
    border-color: rgba(200, 16, 46, 0.3);
}

.analytics-select:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

.analytics-date-input {
    padding: 0.625rem 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    color: #333;
    background: white;
    transition: all 0.2s ease;
}

.analytics-date-input:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

.analytics-apply-btn {
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.2);
}

.analytics-apply-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
}

.custom-dates {
    gap: 0.5rem !important;
}

/* Analytics Summary Cards */
.analytics-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.analytics-summary-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.analytics-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(200, 16, 46, 0.1);
}

.summary-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.summary-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.summary-icon.users-icon {
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
}

.summary-icon.responses-icon {
    background: linear-gradient(135deg, #8B0D22 0%, #A50D25 100%);
}

.summary-content {
    display: flex;
    flex-direction: column;
}

.summary-value {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.75rem;
    color: #1a1a1a;
    line-height: 1.1;
}

.summary-label {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Analytics Charts */
.analytics-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.chart-card:hover {
    box-shadow: 0 8px 24px rgba(200, 16, 46, 0.08);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-header h3 {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    color: #333;
    margin: 0;
}

.chart-period {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.8rem;
    color: #999;
}

.chart-container {
    min-height: 280px;
    position: relative;
}

.chart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 280px;
    gap: 1rem;
    color: #999;
}

.chart-loading p {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    margin: 0;
}

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 280px;
    color: #999;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
}

/* Responsive styles for analytics */
@media (max-width: 960px) {
    .analytics-section {
        padding: 0;
    }

    .analytics-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .analytics-filters {
        width: 100%;
    }

    .analytics-charts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .analytics-filters .filter-group {
        flex-wrap: wrap;
    }

    .analytics-select,
    .analytics-date-input {
        width: 100%;
    }

    .custom-dates {
        flex-direction: column;
        width: 100%;
    }

    .analytics-apply-btn {
        width: 100%;
    }

    .chart-container {
        min-height: 220px;
    }
}
/* Training Page */
.training-shell {
    min-height: 100vh;
    background: linear-gradient(160deg, #f8f8f7 0%, #f1f5f9 100%);
    padding: 1.25rem;
}

.training-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.training-header h1 {
    margin: 0;
    font-size: 1.6rem;
}

.training-header p {
    margin: 0.25rem 0 0;
    color: #64748b;
}

.training-header-actions {
    display: flex;
    gap: 0.5rem;
}

.training-header-actions button,
.training-tabs button,
.training-content button {
    border: 1px solid #d6dce5;
    background: #ffffff;
    border-radius: 10px;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
}

.training-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.training-tabs button.active {
    background: #7a0019;
    color: #ffffff;
    border-color: #7a0019;
}

.training-content h2 {
    margin-top: 0;
}

.training-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 0.9rem;
}

.training-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.training-card ul {
    margin: 0;
    padding-left: 1rem;
}

.training-card li {
    margin-bottom: 0.55rem;
}

.training-card input,
.training-card textarea,
.training-card select {
    width: 100%;
    margin-bottom: 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.5rem;
    font: inherit;
    box-sizing: border-box;
}

.training-section {
    border-top: 1px dashed #e2e8f0;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
}

.training-question {
    border-top: 1px dashed #e2e8f0;
    margin-top: 0.8rem;
    padding-top: 0.8rem;
}

.training-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.35rem;
}

.training-inline-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.3rem;
}

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

    .training-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ====================================
   TRAINING ADMIN SECTIONS
   ==================================== */

.ta-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .ta-layout {
        grid-template-columns: 1fr;
    }
}

.ta-layout-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1200px) {
    .ta-layout-3col {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 800px) {
    .ta-layout-3col {
        grid-template-columns: 1fr;
    }
}

.ta-form-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid rgba(200, 16, 46, 0.08);
    padding: 1.75rem;
    box-shadow: 0 4px 20px rgba(200, 16, 46, 0.06);
}

.ta-form-card h3 {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.05rem;
    color: #C8102E;
    margin: 0 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ta-form-card h3 svg {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

.ta-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ta-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.ta-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ta-field input,
.ta-field textarea,
.ta-field select {
    padding: 0.65rem 0.85rem;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.92rem;
    background: #fff;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.ta-field input:focus,
.ta-field textarea:focus,
.ta-field select:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
}

.ta-field textarea {
    resize: vertical;
    min-height: 60px;
}

.ta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.ta-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #555;
    cursor: pointer;
}

.ta-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #C8102E;
    cursor: pointer;
}

.ta-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem 1.25rem;
    margin-top: 0.5rem;
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(200, 16, 46, 0.2);
}

.ta-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(200, 16, 46, 0.3);
    background: linear-gradient(135deg, #A50D25 0%, #C8102E 100%);
}

.ta-submit-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ta-submit-btn svg {
    width: 18px;
    height: 18px;
}

/* List area */
.ta-list-area {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid rgba(200, 16, 46, 0.08);
    box-shadow: 0 4px 20px rgba(200, 16, 46, 0.06);
    overflow: hidden;
}

.ta-list-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.ta-list-header h3 {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    color: #1e1e1e;
    margin: 0;
}

.ta-list-count {
    font-size: 0.8rem;
    color: #fff;
    background: #C8102E;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
}

.ta-list-scroll {
    max-height: 600px;
    overflow-y: auto;
}

.ta-list-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: #999;
    font-size: 0.95rem;
}

.ta-list-empty svg {
    width: 48px;
    height: 48px;
    color: #ddd;
    margin-bottom: 0.75rem;
}

/* Table inside list area */
.ta-table {
    width: 100%;
    border-collapse: collapse;
}

.ta-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.ta-table th {
    background: rgba(200, 16, 46, 0.04);
    padding: 0.7rem 1rem;
    text-align: left;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    white-space: nowrap;
}

.ta-table td {
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    color: #333;
}

.ta-table tbody tr {
    transition: background 0.15s ease;
}

.ta-table tbody tr:hover {
    background: rgba(200, 16, 46, 0.03);
}

.ta-table .ta-title-cell {
    font-weight: 600;
    color: #1e1e1e;
}

.ta-table .ta-id-cell {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    color: #888;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status pills */
.ta-status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: capitalize;
}

.ta-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.ta-status.published,
.ta-status.active {
    background: rgba(34, 197, 94, 0.1);
    color: #15803d;
}
.ta-status.published::before,
.ta-status.active::before {
    background: #22c55e;
}

.ta-status.draft,
.ta-status.scheduled {
    background: rgba(234, 179, 8, 0.1);
    color: #a16207;
}
.ta-status.draft::before,
.ta-status.scheduled::before {
    background: #eab308;
}

.ta-status.archived,
.ta-status.closed,
.ta-status.cancelled {
    background: rgba(107, 114, 128, 0.1);
    color: #4b5563;
}
.ta-status.archived::before,
.ta-status.closed::before,
.ta-status.cancelled::before {
    background: #9ca3af;
}

.ta-status.locked {
    background: rgba(200, 16, 46, 0.1);
    color: #C8102E;
}
.ta-status.locked::before {
    background: #C8102E;
}

/* Mini badges */
.ta-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.78rem;
    color: #666;
    background: rgba(0, 0, 0, 0.04);
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
}

.ta-badge svg {
    width: 12px;
    height: 12px;
}

.ta-badge.mandatory {
    background: rgba(200, 16, 46, 0.08);
    color: #C8102E;
}

/* Utility section */
.ta-utility-section {
    margin-top: 1.5rem;
}

.ta-utility-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid rgba(200, 16, 46, 0.08);
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(200, 16, 46, 0.06);
}

.ta-utility-card h3 {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    color: #C8102E;
    margin: 0 0 1rem;
}

.ta-utility-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.ta-section-divider {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    margin: 1.25rem 0;
    padding-top: 1.25rem;
}

/* Question bank modal */
/* =========================================
   QUESTION BANK MODAL — Redesigned
   ========================================= */
.qb-modal {
    width: min(96vw, 1220px);
    max-width: 1220px;
    border-radius: 20px;
    overflow: hidden;
    border: none;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 24px 80px rgba(0, 0, 0, 0.18),
        0 8px 24px rgba(0, 0, 0, 0.08);
    background: #FAFAFA;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.qb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
    background: #FFFFFF;
    border-bottom: 1px solid #ECECEE;
    flex-shrink: 0;
}

.qb-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.qb-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #C8102E 0%, #9A0E26 100%);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.qb-header h2 {
    margin: 0;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.18rem;
    color: #111111;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.qb-header-subtitle {
    margin: 0.1rem 0 0;
    font-size: 0.82rem;
    color: #6B7280;
    line-height: 1;
}

.qb-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: #6B7280;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.qb-close-btn:hover {
    background: #F3F4F6;
    color: #111;
    border-color: #D1D5DB;
}

/* Body */
.qb-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem 1.25rem;
}

/* Layout */
.qb-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1.25rem;
    align-items: start;
}

/* Config column */
.qb-config-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Section (details/summary accordion) */
.qb-section {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.qb-section[open] {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.qb-section-summary {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 0.85rem;
    cursor: pointer;
    user-select: none;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.88rem;
    color: #1F2937;
    list-style: none;
    transition: background 0.15s ease;
}

.qb-section-summary::-webkit-details-marker { display: none; }

.qb-section-summary:hover {
    background: #F9FAFB;
}

.qb-section-summary svg {
    color: #9CA3AF;
    flex-shrink: 0;
}

.qb-section[open] > .qb-section-summary svg {
    color: #C8102E;
}

.qb-section-body {
    padding: 0 0.85rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

/* Fields */
.qb-field {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
}

.qb-field label {
    font-size: 0.76rem;
    font-weight: 600;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.qb-row-fields {
    display: flex;
    gap: 0.55rem;
}

.qb-row-fields > .qb-field { flex: 1; }

/* Inputs */
.qb-input {
    width: 100%;
    padding: 0.48rem 0.6rem;
    border: 1px solid #E5E7EB;
    border-radius: 9px;
    font-size: 0.86rem;
    color: #111827;
    background: #FFFFFF;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
    font-family: inherit;
    resize: vertical;
}

.qb-input:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
}

textarea.qb-input { min-height: 48px; }

.qb-select {
    width: 100%;
    padding: 0.48rem 0.6rem;
    border: 1px solid #E5E7EB;
    border-radius: 9px;
    font-size: 0.86rem;
    color: #111827;
    background: #FFFFFF;
    cursor: pointer;
    box-sizing: border-box;
}

.qb-select:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
}

/* Buttons */
.qb-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 9px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}

.qb-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.qb-btn-primary {
    background: #C8102E;
    color: #FFFFFF;
}

.qb-btn-primary:hover:not(:disabled) {
    background: #A30D25;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.25);
}

.qb-btn-sm {
    padding: 0.38rem 0.75rem;
    font-size: 0.8rem;
}

.qb-btn-ghost {
    background: transparent;
    color: #6B7280;
    border: 1px solid #E5E7EB;
}

.qb-btn-ghost:hover:not(:disabled) {
    background: #F3F4F6;
    color: #374151;
}

.qb-btn-danger {
    background: transparent;
    color: #DC2626;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.qb-btn-danger:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.06);
    border-color: rgba(220, 38, 38, 0.35);
}

.qb-btn-ai {
    background: linear-gradient(135deg, #1E1B4B 0%, #312E81 50%, #4338CA 100%);
    color: #FFFFFF;
    width: 100%;
    justify-content: center;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 9px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.qb-btn-ai:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(67, 56, 202, 0.35);
    transform: translateY(-1px);
}

.qb-btn-ai:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Spinner */
@keyframes qb-spin {
    to { transform: rotate(360deg); }
}

.qb-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: qb-spin 0.6s linear infinite;
    display: inline-block;
}

/* Options box (manual + edit) */
.qb-options-box {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 0.6rem 0.7rem;
}

.qb-options-label {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.qb-option-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.35rem;
}

.qb-option-row:last-of-type {
    margin-bottom: 0;
}

.qb-option-radio-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 8px;
    border: 1.5px solid #D1D5DB;
    background: #FFFFFF;
    color: #9CA3AF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0;
}

.qb-option-radio-btn:hover {
    border-color: #9CA3AF;
}

.qb-option-radio-btn.correct {
    background: #059669;
    border-color: #059669;
    color: #FFFFFF;
}

.qb-option-letter {
    font-size: 0.72rem;
    font-weight: 700;
}

.qb-option-remove {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #9CA3AF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}

.qb-option-remove:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #DC2626;
}

.qb-add-option-btn {
    display: block;
    margin-top: 0.35rem;
    padding: 0.3rem 0;
    background: none;
    border: none;
    color: #6B7280;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.15s;
}

.qb-add-option-btn:hover {
    color: #C8102E;
}

.qb-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.84rem;
    color: #374151;
    cursor: pointer;
    user-select: none;
}

.qb-checkbox-label input { margin: 0; }

/* Questions column */
.qb-questions-col {
    min-height: 200px;
}

.qb-questions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.qb-questions-header h3 {
    margin: 0;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qb-questions-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(200, 16, 46, 0.1);
    color: #C8102E;
    font-size: 0.76rem;
    font-weight: 700;
}

/* Empty state */
.qb-empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    background: #FFFFFF;
    border: 2px dashed #E5E7EB;
    border-radius: 16px;
    color: #9CA3AF;
}

.qb-empty-state p {
    margin: 0.75rem 0 0.25rem;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #6B7280;
}

.qb-empty-state span {
    font-size: 0.82rem;
    color: #9CA3AF;
}

/* Question list */
.qb-question-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.qb-question-item {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    transition: all 0.18s ease;
    overflow: hidden;
}

.qb-question-item:hover {
    border-color: #D1D5DB;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.qb-question-item.expanded {
    border-color: rgba(200, 16, 46, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.qb-question-item.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.qb-question-item.drop-target {
    border-color: #C8102E;
    box-shadow: 0 0 0 2px rgba(200, 16, 46, 0.12);
}

/* Question row (always visible) */
.qb-question-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    user-select: none;
}

.qb-drag-handle {
    color: #D1D5DB;
    cursor: grab;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.qb-question-item:hover .qb-drag-handle {
    color: #9CA3AF;
}

.qb-question-num {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: #F3F4F6;
    color: #6B7280;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.qb-question-item.expanded .qb-question-num {
    background: rgba(200, 16, 46, 0.1);
    color: #C8102E;
}

.qb-question-text {
    margin: 0;
    flex: 1;
    font-size: 0.84rem;
    color: #1F2937;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.qb-question-meta {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}

.qb-options-badge {
    font-size: 0.7rem;
    color: #9CA3AF;
    background: #F3F4F6;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    font-weight: 600;
}

.qb-expand-icon {
    color: #D1D5DB;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.15s;
}

.qb-expand-icon.open {
    transform: rotate(180deg);
    color: #C8102E;
}

/* Question detail (expanded) */
.qb-question-detail {
    padding: 0 0.75rem 0.75rem;
    border-top: 1px solid #F3F4F6;
}

.qb-detail-options {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.6rem;
}

.qb-detail-option {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.55rem;
    border-radius: 8px;
    font-size: 0.82rem;
    color: #374151;
    background: #F9FAFB;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.qb-detail-option.correct {
    background: rgba(5, 150, 105, 0.06);
    border-color: rgba(5, 150, 105, 0.15);
    color: #065F46;
}

.qb-detail-option-letter {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: #E5E7EB;
    color: #6B7280;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.qb-detail-option.correct .qb-detail-option-letter {
    background: #059669;
    color: #FFFFFF;
}

.qb-correct-check {
    margin-left: auto;
    color: #059669;
    flex-shrink: 0;
}

.qb-detail-explanation {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
    color: #6B7280;
    line-height: 1.45;
    padding: 0.4rem 0.55rem;
    background: #FFFBEB;
    border-radius: 8px;
    border: 1px solid rgba(245, 158, 11, 0.15);
}

.qb-detail-explanation strong {
    color: #92400E;
}

.qb-detail-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.6rem;
    justify-content: flex-end;
}

/* Edit form */
.qb-edit-form {
    padding-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.qb-edit-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
    margin-top: 0.2rem;
}

/* Responsive */
@media (max-width: 1080px) {
    .qb-modal {
        width: min(97vw, 980px);
    }

    .qb-layout {
        grid-template-columns: 1fr;
    }

    .qb-config-col {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
}

@media (max-width: 768px) {
    .qb-modal {
        border-radius: 14px;
    }

    .qb-header h2 {
        font-size: 1.05rem;
    }

    .qb-body {
        padding: 0.75rem;
    }

    .qb-config-col {
        grid-template-columns: 1fr;
    }

    .qb-row-fields {
        flex-direction: column;
    }

    .qb-question-row {
        padding: 0.5rem 0.6rem;
    }
}

/* =========================================
   COURSE BUILDER - Unified Courses & Content
   ========================================= */

/* Header */
.cb-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cb-new-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    background: #C8102E;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.cb-new-btn svg {
    width: 18px;
    height: 18px;
}
.cb-new-btn:hover {
    background: #a00d24;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
}
.cb-new-btn.secondary {
    background: rgba(200, 16, 46, 0.08);
    color: #C8102E;
}
.cb-new-btn.secondary:hover {
    background: rgba(200, 16, 46, 0.15);
    box-shadow: none;
}

/* Search */
.cb-search-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 0.6rem 1rem;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s;
}
.cb-search-bar:focus-within {
    border-color: rgba(200, 16, 46, 0.3);
}
.cb-search-bar svg {
    width: 20px;
    height: 20px;
    color: #999;
    flex-shrink: 0;
}
.cb-search-bar input {
    border: 1.5px solid rgba(15, 23, 42, 0.14);
    background: #fff;
    flex: 1;
    min-width: 220px;
    border-radius: 10px;
    padding: 0.55rem 0.75rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #333;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.cb-search-bar input::placeholder {
    color: #aaa;
}
.cb-search-bar input:focus {
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
}
.cb-search-bar select {
    min-width: 170px;
    height: 40px;
    border: 1.5px solid rgba(15, 23, 42, 0.14);
    border-radius: 10px;
    padding: 0.55rem 2rem 0.55rem 0.75rem;
    background-color: #fff;
    color: #1f2937;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    line-height: 1.2;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.cb-search-bar select:focus {
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
}

.ta-field select,
.cb-search-bar select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1.41.59 6 5.17 10.59.59 12 2l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 12px 8px;
}

.servsafe-view-tabs {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.servsafe-view-tab {
    border: 1px solid rgba(15, 23, 42, 0.16);
    background: #fff;
    color: #4b5563;
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.servsafe-view-tab:hover {
    border-color: rgba(200, 16, 46, 0.4);
    color: #C8102E;
}

.servsafe-view-tab.active {
    background: rgba(200, 16, 46, 0.12);
    border-color: rgba(200, 16, 46, 0.35);
    color: #C8102E;
}

/* ServSafe Admin Upload */
.servsafe-admin-upload-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.servsafe-admin-file-input {
    min-width: 260px;
    flex: 1 1 340px;
    padding: 0.45rem 0.6rem;
    border: 1.5px solid rgba(15, 23, 42, 0.14);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.servsafe-admin-file-input:hover {
    border-color: rgba(200, 16, 46, 0.4);
    background: #fff;
}

.servsafe-admin-file-input:focus {
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
    outline: none;
}

.servsafe-admin-file-input::file-selector-button {
    margin-right: 12px;
    border: 0;
    border-radius: 8px;
    padding: 0.4rem 0.85rem;
    background: rgba(200, 16, 46, 0.1);
    color: #C8102E;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.servsafe-admin-file-input::file-selector-button:hover {
    background: rgba(200, 16, 46, 0.18);
}

.servsafe-admin-file-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .servsafe-admin-file-input {
        min-width: 0;
        width: 100%;
    }
    .servsafe-admin-upload-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Empty state */
.cb-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 2rem;
    text-align: center;
    color: #999;
}
.cb-empty svg {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}
.cb-empty p {
    font-size: 1rem;
    margin: 0;
}

/* Course Grid */
.cb-course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* Course Card */
.cb-course-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.cb-course-card:hover {
    border-color: rgba(200, 16, 46, 0.2);
    box-shadow: 0 6px 24px rgba(200, 16, 46, 0.08);
    transform: translateY(-2px);
}

.cb-card-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cb-mandatory-tag {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #C8102E;
    background: rgba(200, 16, 46, 0.08);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.cb-card-title {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.05rem;
    color: #222;
    margin: 0;
    line-height: 1.3;
}

.cb-card-summary {
    font-size: 0.85rem;
    color: #777;
    margin: 0;
    line-height: 1.4;
}

.cb-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}
.cb-card-meta span {
    font-size: 0.78rem;
    color: #888;
}
.cb-wf-dot {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.04);
}
.cb-wf-dot.success { background: rgba(40, 167, 69, 0.1); color: #28a745; }
.cb-wf-dot.warning { background: rgba(255, 193, 7, 0.15); color: #d39e00; }
.cb-wf-dot.danger { background: rgba(200, 16, 46, 0.08); color: #C8102E; }

/* Modal */
.cb-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}
.cb-modal {
    background: #fff;
    border-radius: 18px;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: cbModalIn 0.25s ease;
}
@keyframes cbModalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.cb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.cb-modal-header h3 {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.15rem;
    color: #222;
    margin: 0;
}
.cb-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: #999;
    border-radius: 8px;
    transition: all 0.15s;
}
.cb-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}
.cb-modal-close svg {
    width: 22px;
    height: 22px;
}
.cb-modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.cb-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.cb-btn-cancel {
    padding: 0.6rem 1.25rem;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    color: #666;
    cursor: pointer;
    transition: all 0.15s;
}
.cb-btn-cancel:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.2);
}

/* Detail View */
.cb-detail-header {
    margin-bottom: 2rem;
}
.cb-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: #C8102E;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.4rem 0;
    margin-bottom: 1rem;
    transition: opacity 0.15s;
}
.cb-back-btn:hover { opacity: 0.7; }
.cb-back-btn svg {
    width: 20px;
    height: 20px;
}

.cb-detail-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.cb-detail-badges {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}
.cb-meta-pill {
    font-size: 0.78rem;
    color: #888;
    background: rgba(0, 0, 0, 0.04);
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
}
.cb-meta-pill.small {
    font-size: 0.72rem;
    padding: 0.1rem 0.4rem;
}
.cb-detail-summary {
    margin: 0.75rem 0 0;
    font-size: 0.92rem;
    color: #666;
    line-height: 1.5;
    max-width: 640px;
}
.cb-detail-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}
.cb-action-btn {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    background: #fff;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    color: #555;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.cb-action-btn:hover { background: #f5f5f5; }
.cb-action-btn.primary { background: #C8102E; color: #fff; border-color: #C8102E; }
.cb-action-btn.primary:hover { background: #a00d24; }
.cb-action-btn.success { background: rgba(40, 167, 69, 0.08); color: #28a745; border-color: rgba(40, 167, 69, 0.2); }
.cb-action-btn.success:hover { background: rgba(40, 167, 69, 0.15); }
.cb-action-btn.danger { background: rgba(200, 16, 46, 0.06); color: #C8102E; border-color: rgba(200, 16, 46, 0.15); }
.cb-action-btn.danger:hover { background: rgba(200, 16, 46, 0.12); }

/* Content Area */
.cb-content-area {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    padding: 1.5rem;
}
.cb-content-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.cb-content-header--stacked {
    align-items: flex-start;
    justify-content: space-between;
}
.cb-content-header h3 {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    color: #333;
    margin: 0;
}
.cb-structure-subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.84rem;
    color: #727272;
}
.cb-content-count {
    font-size: 0.8rem;
    color: #999;
    margin-right: auto;
}
.cb-content-header-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.cb-structure-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.cb-structure-stats span {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 999px;
    padding: 0.22rem 0.65rem;
    color: #555;
    font-size: 0.78rem;
}
.cb-structure-stats strong {
    color: #C8102E;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    margin-right: 0.2rem;
}
.cb-add-section-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    background: rgba(200, 16, 46, 0.06);
    color: #C8102E;
    border: 1px solid rgba(200, 16, 46, 0.12);
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
}
.cb-add-section-btn svg {
    width: 16px;
    height: 16px;
}
.cb-add-section-btn:hover {
    background: rgba(200, 16, 46, 0.12);
}

@media (max-width: 900px) {
    .cb-content-header--stacked {
        flex-direction: column;
    }
    .cb-content-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* Inline Form */
.cb-inline-form {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(200, 16, 46, 0.1);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    animation: cbSlideDown 0.2s ease;
}
@keyframes cbSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.cb-inline-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.5rem;
}

/* Image Upload Card */
.cb-image-upload-card {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid #e5e5ea;
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.25s ease;
}
.cb-image-upload-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

/* Empty sections */
.cb-empty-sections {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2.5rem 1rem;
    color: #bbb;
    text-align: center;
}
.cb-empty-sections svg {
    width: 36px;
    height: 36px;
    opacity: 0.35;
}
.cb-empty-sections p {
    font-size: 0.9rem;
    margin: 0;
    max-width: 320px;
}

/* Modules List */
.cb-modules-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cb-module-item {
    border: 1.5px solid rgba(200, 16, 46, 0.12);
    border-radius: 14px;
    overflow: hidden;
    transition: border-color 0.2s;
    background: #fff;
}
.cb-module-item.expanded {
    border-color: rgba(200, 16, 46, 0.25);
}

.cb-module-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.1rem;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
    background: linear-gradient(135deg, rgba(200, 16, 46, 0.03) 0%, rgba(200, 16, 46, 0.06) 100%);
    border-bottom: 1px solid rgba(200, 16, 46, 0.08);
}
.cb-module-header:hover {
    background: linear-gradient(135deg, rgba(200, 16, 46, 0.05) 0%, rgba(200, 16, 46, 0.09) 100%);
}

.cb-module-order {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #C8102E;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 8px;
    flex-shrink: 0;
}
.cb-module-name {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #C8102E;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cb-module-desc {
    font-size: 0.8rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cb-module-meta {
    font-size: 0.72rem;
    color: #999;
    white-space: nowrap;
}

.cb-module-body {
    padding: 0.75rem 0.9rem 0.9rem;
}

.cb-module-add-section-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1.5px dashed rgba(200, 16, 46, 0.25);
    color: #C8102E;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: background 0.15s, border-color 0.15s;
}
.cb-module-add-section-btn:hover {
    background: rgba(200, 16, 46, 0.04);
    border-color: rgba(200, 16, 46, 0.4);
}
.cb-module-add-section-btn svg {
    width: 16px;
    height: 16px;
}

.cb-orphan-sections-label {
    font-size: 0.82rem;
    color: #999;
    font-weight: 600;
    padding: 0.75rem 0 0.25rem;
    border-top: 1px dashed rgba(0,0,0,0.08);
    margin-top: 0.75rem;
}

/* Sections List */
.cb-sections-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cb-section-item {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.cb-section-item.expanded {
    border-color: rgba(200, 16, 46, 0.15);
}
.cb-section-item.drop-target,
.cb-module-item.drop-target {
    border-color: #C8102E;
    box-shadow: 0 0 0 2px rgba(200, 16, 46, 0.14);
}

.cb-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}
.cb-section-header:hover {
    background: rgba(0, 0, 0, 0.02);
}

.cb-chevron {
    width: 20px;
    height: 20px;
    color: #999;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.cb-section-item.expanded .cb-chevron {
    transform: rotate(0deg);
}
.cb-section-item:not(.expanded) .cb-chevron {
    transform: rotate(-90deg);
}

.cb-section-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}
.cb-section-order {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(200, 16, 46, 0.08);
    color: #C8102E;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 6px;
    flex-shrink: 0;
}
.cb-section-name {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.92rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cb-section-desc {
    font-size: 0.8rem;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.cb-section-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.cb-drag-handle {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.05);
    cursor: grab;
    transition: background 0.16s ease, color 0.16s ease;
}
.cb-drag-handle svg {
    width: 16px;
    height: 16px;
}
.cb-drag-handle:hover {
    background: rgba(200, 16, 46, 0.1);
    color: #C8102E;
}
.cb-drag-handle.dragging {
    opacity: 0.6;
}
.cb-lesson-count {
    font-size: 0.78rem;
    color: #999;
}

/* Section Body (expanded) */
.cb-section-body {
    padding: 0 1rem 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    animation: cbSlideDown 0.2s ease;
}

.cb-no-lessons {
    font-size: 0.85rem;
    color: #bbb;
    padding: 1rem 0 0.5rem;
    text-align: center;
}

/* Lessons List */
.cb-lessons-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-top: 0.75rem;
}

.cb-lesson-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    transition: background 0.15s;
}
.cb-lesson-row:hover {
    background: rgba(0, 0, 0, 0.02);
}
.cb-lesson-row.drop-target {
    background: rgba(200, 16, 46, 0.08);
    box-shadow: inset 0 0 0 1px rgba(200, 16, 46, 0.24);
}

.cb-lesson-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(200, 16, 46, 0.06);
    border-radius: 8px;
    flex-shrink: 0;
}
.cb-lesson-icon svg {
    width: 16px;
    height: 16px;
    color: #C8102E;
}

.cb-lesson-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}
.cb-lesson-title {
    font-size: 0.88rem;
    color: #333;
    font-weight: 500;
}
.cb-lesson-tags {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.cb-tag {
    font-size: 0.7rem;
    color: #999;
    background: rgba(0, 0, 0, 0.04);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    text-transform: lowercase;
}

/* Add Lesson Button */
.cb-add-lesson-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.75rem;
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px dashed rgba(200, 16, 46, 0.2);
    border-radius: 8px;
    color: #C8102E;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    justify-content: center;
}
.cb-add-lesson-btn svg {
    width: 16px;
    height: 16px;
}
.cb-add-lesson-btn:hover {
    background: rgba(200, 16, 46, 0.04);
    border-color: rgba(200, 16, 46, 0.3);
}

/* Lesson Form */
.cb-lesson-form {
    margin-top: 0.75rem;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(200, 16, 46, 0.1);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    animation: cbSlideDown 0.2s ease;
}

.cb-lesson-preview {
    margin-top: 0.2rem;
    padding: 0.85rem;
    border: 1px solid rgba(200, 16, 46, 0.16);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(200, 16, 46, 0.04), rgba(200, 16, 46, 0.01));
}
.cb-lesson-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.cb-lesson-preview-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.cb-lesson-preview-header h4 {
    margin: 0;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    color: #3b3b3f;
}
.cb-lesson-preview-empty {
    margin: 0.65rem 0 0;
    padding: 0.75rem;
    border-radius: 10px;
    background: #fff;
    border: 1px dashed rgba(0, 0, 0, 0.1);
    color: #7a7a82;
    font-size: 0.83rem;
}
.cb-lesson-preview-panel {
    margin-top: 0.7rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: #fff;
}
.cb-lesson-preview-media {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.cb-lesson-preview-media .t-detail-video,
.cb-lesson-preview-media iframe {
    width: 100%;
    min-height: 220px;
    border: none;
    border-radius: 12px;
    background: #0f1118;
}
.cb-lesson-preview-secondary {
    margin-top: 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.admin-lesson-preview-page {
    height: 100vh;
    min-height: 100vh;
    background: #f4f5f8;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.admin-lesson-preview-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
}
.admin-lesson-preview-topbar-left {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}
.admin-lesson-preview-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #C8102E;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
}
.admin-lesson-preview-link:hover {
    text-decoration: underline;
}
.admin-lesson-preview-pill {
    font-size: 0.74rem;
    padding: 0.14rem 0.5rem;
    border-radius: 999px;
    color: #4a4a52;
    background: rgba(0, 0, 0, 0.06);
}
.admin-lesson-preview-time {
    font-size: 0.75rem;
    color: #666;
}
.admin-lesson-preview-content {
    margin: 0 auto;
    max-width: 1320px;
}
.admin-lesson-preview-empty-wrap {
    max-width: 760px;
    margin: 4rem auto 0;
    padding: 1.25rem;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    text-align: center;
}
.admin-lesson-preview-empty-wrap h1 {
    margin: 0;
    font-size: 1.1rem;
    color: #1f1f23;
}
.admin-lesson-preview-empty-wrap p {
    margin: 0.6rem 0 0;
    color: #63636b;
    font-size: 0.9rem;
}

.cb-lesson-form-advanced {
    margin-top: 0.25rem;
}
.cb-lesson-form-advanced details {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    overflow: hidden;
}
.cb-lesson-form-advanced summary {
    padding: 0.6rem 0.85rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.82rem;
    color: #888;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}
.cb-lesson-form-advanced summary:hover {
    background: rgba(0, 0, 0, 0.02);
}
.cb-advanced-fields {
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

/* Rich text editor inside course builder */
.cb-lesson-form .rich-editor,
.cb-advanced-fields .rich-editor {
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
}
.cb-lesson-form .rich-editor-content,
.cb-advanced-fields .rich-editor-content {
    min-height: 120px;
    padding: 0.85rem;
    font-size: 0.9rem;
}

/* ───────────────────────────────────────────────────────────────────
   COURSE BROWSER — Finder-style 3-panel navigation
   ─────────────────────────────────────────────────────────────────── */

/* Breadcrumb */
.cb-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: #999;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.cb-breadcrumb-item {
    background: none;
    border: none;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.82rem;
    color: #C8102E;
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    transition: background 0.15s;
}
.cb-breadcrumb-item:hover {
    background: rgba(200, 16, 46, 0.06);
}
.cb-breadcrumb-item.current {
    color: #333;
    cursor: default;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
}
.cb-breadcrumb-item.current:hover {
    background: transparent;
}
.cb-breadcrumb-sep {
    color: #ccc;
    font-size: 0.75rem;
    user-select: none;
}

/* Finder layout */
.cb-finder {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    overflow: hidden;
    min-height: 480px;
}

.cb-finder-sidebar {
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    background: rgba(248, 248, 250, 0.6);
}

.cb-finder-sidebar-header {
    padding: 1rem 1rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.cb-finder-sidebar-header h3 {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.82rem;
    color: #666;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.cb-finder-sidebar-add {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #C8102E;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}
.cb-finder-sidebar-add:hover {
    background: rgba(200, 16, 46, 0.08);
}
.cb-finder-sidebar-add svg {
    width: 18px;
    height: 18px;
}

.cb-finder-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.35rem 0;
}

.cb-finder-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1rem;
    cursor: pointer;
    transition: background 0.12s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    position: relative;
}
.cb-finder-item:hover {
    background: rgba(0, 0, 0, 0.03);
}
.cb-finder-item.active {
    background: rgba(200, 16, 46, 0.08);
}
.cb-finder-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #C8102E;
}
.cb-finder-item.cb-wiki-finder-item {
    padding-left: calc(1rem + (var(--depth, 0) * 14px));
}
.cb-finder-item.cb-wiki-finder-item .cb-meta-pill {
    margin-left: 0.4rem;
}
.cb-finder-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
    font-size: 1.1rem;
}
.cb-finder-item-icon svg,
.cb-finder-item-icon [data-lucide] {
    width: 18px;
    height: 18px;
}
.cb-finder-item-text {
    flex: 1;
    min-width: 0;
}
.cb-finder-item-name {
    font-size: 0.88rem;
    color: #333;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cb-finder-item-meta {
    font-size: 0.72rem;
    color: #999;
    display: block;
    margin-top: 1px;
}
.cb-finder-item-chevron {
    width: 16px;
    height: 16px;
    color: #ccc;
    flex-shrink: 0;
    transition: color 0.15s;
}
.cb-finder-item.active .cb-finder-item-chevron {
    color: #C8102E;
}

/* Main content panel */
.cb-finder-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cb-finder-main-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.cb-finder-main-header h3 {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    color: #222;
    margin: 0;
}
.cb-finder-main-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.cb-finder-main-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

/* Subcategory cards */
.cb-subcategory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.cb-subcategory-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.cb-subcategory-card:hover {
    border-color: rgba(200, 16, 46, 0.2);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.06);
    transform: translateY(-1px);
}
.cb-subcategory-card.active {
    border-color: rgba(200, 16, 46, 0.3);
    background: rgba(200, 16, 46, 0.04);
}
.cb-subcategory-card-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.cb-subcategory-card-icon svg,
.cb-subcategory-card-icon [data-lucide] {
    width: 18px;
    height: 18px;
}
.cb-subcategory-card-text {
    flex: 1;
    min-width: 0;
}
.cb-subcategory-card-name {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.88rem;
    color: #333;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cb-subcategory-card-meta {
    font-size: 0.72rem;
    color: #999;
    display: block;
    margin-top: 2px;
}
.cb-subcategory-card-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.cb-subcategory-card:hover .cb-subcategory-card-actions {
    opacity: 1;
}

.cb-wiki-layout {
    display: grid;
    grid-template-columns: minmax(290px, 360px) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.cb-wiki-categories-panel,
.cb-wiki-articles-panel {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.03);
}

.cb-wiki-categories-body {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 0.65rem;
}

.cb-wiki-category-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 540px;
    overflow: auto;
    padding-right: 0.25rem;
}

.cb-wiki-category-item {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    background: #fff;
    padding: 0.55rem 0.65rem 0.6rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.cb-wiki-category-item.active {
    border-color: rgba(200, 16, 46, 0.4);
    background: rgba(200, 16, 46, 0.04);
    box-shadow: 0 3px 10px rgba(200, 16, 46, 0.08);
}

.cb-wiki-category-main {
    width: 100%;
    border: none;
    background: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0.25rem 0.25rem 0.2rem;
    padding-left: calc(var(--depth, 0) * 14px + 0.25rem);
    gap: 0.5rem;
}

.cb-wiki-category-name {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    color: #1f2937;
    text-align: left;
}

.cb-wiki-category-count {
    min-width: 30px;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    background: rgba(0, 0, 0, 0.06);
    color: #555;
    text-align: center;
}

.cb-wiki-category-item.active .cb-wiki-category-count {
    background: rgba(200, 16, 46, 0.15);
    color: #C8102E;
}

.cb-wiki-category-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.74rem;
    color: #8b8b8b;
    padding-left: calc(var(--depth, 0) * 14px + 0.35rem);
}

/* Inline icon button */
.cb-icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    color: #888;
    transition: all 0.15s;
}
.cb-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}
.cb-icon-btn svg {
    width: 16px;
    height: 16px;
}

/* Category info bar */
.cb-category-info-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: rgba(200, 16, 46, 0.03);
    border: 1px solid rgba(200, 16, 46, 0.08);
    border-radius: 12px;
    margin-bottom: 1rem;
}
.cb-category-info-bar-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.cb-category-info-bar-icon svg,
.cb-category-info-bar-icon [data-lucide] {
    width: 20px;
    height: 20px;
}
.cb-category-info-bar-text {
    flex: 1;
    min-width: 0;
}
.cb-category-info-bar-name {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #222;
}
.cb-category-info-bar-desc {
    font-size: 0.82rem;
    color: #888;
    margin-top: 2px;
}
.cb-category-info-bar-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* Finder empty state */
.cb-finder-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 2rem;
    text-align: center;
    color: #bbb;
    flex: 1;
}
.cb-finder-empty svg {
    width: 40px;
    height: 40px;
    opacity: 0.25;
}
.cb-finder-empty p {
    font-size: 0.9rem;
    margin: 0;
    max-width: 260px;
    line-height: 1.4;
}

/* Section divider label */
.cb-section-label {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.72rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1.25rem 0.35rem;
}

/* Permissions panel */
.cb-permissions-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.75rem;
}
.cb-permission-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    transition: background 0.15s;
}
.cb-permission-row:hover {
    background: rgba(0, 0, 0, 0.02);
}
.cb-permission-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(200, 16, 46, 0.08);
    color: #C8102E;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.cb-permission-info {
    flex: 1;
    min-width: 0;
}
.cb-permission-name {
    font-size: 0.88rem;
    color: #333;
    display: block;
}
.cb-permission-email {
    font-size: 0.72rem;
    color: #999;
    display: block;
}
.cb-permission-remove {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}
.cb-permission-remove:hover {
    background: rgba(200, 16, 46, 0.08);
    color: #C8102E;
}
.cb-permission-remove svg {
    width: 16px;
    height: 16px;
}

/* Permission add row */
.cb-permission-add-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}
.cb-permission-add-row select {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    color: #333;
    background: #fff;
}

/* Tab strip for category detail */
.cb-detail-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 1.25rem;
}
.cb-detail-tab {
    padding: 0.6rem 1rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    color: #888;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}
.cb-detail-tab:hover {
    color: #555;
}
.cb-detail-tab.active {
    color: #C8102E;
    border-bottom-color: #C8102E;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Responsive */
@media (max-width: 768px) {
    .cb-finder {
        grid-template-columns: 1fr;
    }
    .cb-finder-sidebar {
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        max-height: 200px;
    }
    .cb-course-grid {
        grid-template-columns: 1fr;
    }
    .cb-header {
        flex-direction: column;
    }
    .cb-detail-title-row {
        flex-direction: column;
    }
    .cb-section-info {
        flex-wrap: wrap;
    }
    .cb-section-desc {
        display: none;
    }
    .cb-subcategory-grid {
        grid-template-columns: 1fr;
    }
    .cb-subcategory-card-actions {
        opacity: 1;
    }
    .cb-wiki-layout {
        grid-template-columns: 1fr;
    }
    .cb-wiki-category-list {
        max-height: 320px;
    }
}

/* ===================================================================
   USERS PANEL — Redesigned
   =================================================================== */

/* Stats strip */
.users-stats-strip {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.users-stat-chip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(200, 16, 46, 0.1);
    border-radius: 12px;
    min-width: 130px;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.users-stat-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(200, 16, 46, 0.08);
}

.users-stat-chip svg {
    width: 22px;
    height: 22px;
    color: #C8102E;
    flex-shrink: 0;
}

.users-stat-chip.accent-green svg { color: #16a34a; }
.users-stat-chip.accent-green { border-color: rgba(34, 197, 94, 0.15); }
.users-stat-chip.accent-purple svg { color: #9333ea; }
.users-stat-chip.accent-purple { border-color: rgba(168, 85, 247, 0.15); }

.users-stat-chip-data {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.users-stat-chip-value {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.3rem;
    color: #1a1a1a;
}

.users-stat-chip-label {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* Toolbar */
.users-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.users-toolbar-search {
    flex: 1;
    min-width: 260px;
    position: relative;
    display: flex;
    align-items: center;
}

.users-search-icon {
    position: absolute;
    left: 0.9rem;
    width: 18px;
    height: 18px;
    color: #999;
    pointer-events: none;
}

.users-search-input {
    width: 100%;
    padding: 0.7rem 2.5rem 0.7rem 2.75rem;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.9);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.users-search-input:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
}

.users-search-clear {
    position: absolute;
    right: 0.6rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.users-search-clear:hover { background: rgba(0, 0, 0, 0.06); }

.users-search-clear svg {
    width: 16px;
    height: 16px;
    color: #999;
}

/* Filter toggle */
.users-filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.users-filter-toggle input { display: none; }

.users-filter-toggle-track {
    width: 36px;
    height: 20px;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    position: relative;
    transition: background 0.25s ease;
}

.users-filter-toggle input:checked + .users-filter-toggle-track {
    background: #C8102E;
}

.users-filter-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.25s ease;
}

.users-filter-toggle input:checked + .users-filter-toggle-track .users-filter-toggle-thumb {
    transform: translateX(16px);
}

.users-filter-toggle-label {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    color: #666;
}

/* Toolbar action buttons */
.users-toolbar-actions {
    display: flex;
    gap: 0.6rem;
    margin-left: auto;
}

.users-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 1.15rem;
    border: none;
    border-radius: 9px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.users-action-btn svg {
    width: 17px;
    height: 17px;
}

.users-action-btn.primary {
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.25);
}

.users-action-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(200, 16, 46, 0.35);
    background: linear-gradient(135deg, #A50D25 0%, #C8102E 100%);
}

.users-action-btn.secondary {
    background: rgba(200, 16, 46, 0.06);
    color: #C8102E;
    border: 1px solid rgba(200, 16, 46, 0.15);
}

.users-action-btn.secondary:hover {
    background: rgba(200, 16, 46, 0.12);
    border-color: rgba(200, 16, 46, 0.25);
}

.users-action-btn.ghost {
    background: transparent;
    color: #666;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.users-action-btn.ghost:hover {
    background: rgba(0, 0, 0, 0.04);
}

.users-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Table wrap */
.users-table-wrap {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    min-height: 350px;
}

/* Users table overrides */
.users-table thead {
    background: rgba(200, 16, 46, 0.03);
    border-bottom: 1.5px solid rgba(200, 16, 46, 0.12);
}

.users-table th {
    font-size: 0.75rem;
    letter-spacing: 0.8px;
    padding: 0.85rem 1rem;
}

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

.users-col-num {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.users-col-meta {
    font-size: 0.88rem;
    color: #555;
}

/* Identity cell (avatar + name + email stacked) */
.users-cell-identity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.users-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #C8102E 0%, #E8384F 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(200, 16, 46, 0.2);
}

.users-cell-identity-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}

.users-cell-name {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.92rem;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.users-cell-email {
    font-size: 0.78rem;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status badges grouping */
.users-badges {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* Row action buttons */
.users-row-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.users-row-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 7px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.users-row-btn svg {
    width: 14px;
    height: 14px;
}

.users-row-btn.fill {
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: #fff;
    box-shadow: 0 2px 6px rgba(200, 16, 46, 0.18);
}

.users-row-btn.fill:hover {
    box-shadow: 0 4px 10px rgba(200, 16, 46, 0.3);
    transform: translateY(-1px);
}

.users-row-btn.outline {
    background: rgba(168, 85, 247, 0.08);
    color: #7c3aed;
    border: 1px solid rgba(168, 85, 247, 0.18);
}

.users-row-btn.outline:hover {
    background: rgba(168, 85, 247, 0.15);
}

.users-row-btn.danger {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.users-row-btn.danger:hover {
    background: rgba(239, 68, 68, 0.15);
}

.users-row-btn.success {
    background: rgba(34, 197, 94, 0.08);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.15);
}

.users-row-btn.success:hover {
    background: rgba(34, 197, 94, 0.15);
}

.users-row-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===================================================================
   BULK UPLOAD MODAL
   =================================================================== */

.bulk-modal-content {
    max-width: 640px;
}

.bulk-modal-header-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.bulk-modal-icon {
    width: 24px;
    height: 24px;
    color: #C8102E;
}

.bulk-format-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    background: rgba(200, 16, 46, 0.04);
    border: 1px solid rgba(200, 16, 46, 0.08);
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    color: #444;
    line-height: 1.5;
}

.bulk-format-hint svg {
    width: 20px;
    height: 20px;
    color: #C8102E;
    flex-shrink: 0;
    margin-top: 1px;
}

.bulk-format-hint code {
    background: rgba(200, 16, 46, 0.08);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.82rem;
    color: #C8102E;
    font-weight: 600;
}

.bulk-format-example {
    font-size: 0.8rem;
    color: #999;
}

.bulk-textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: rgba(0, 0, 0, 0.015);
    box-sizing: border-box;
}

.bulk-textarea:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
    background: white;
}

.bulk-line-count {
    text-align: right;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.75rem;
    color: #aaa;
    margin-top: 0.35rem;
    margin-bottom: 0.5rem;
}

/* Preview results */
.bulk-preview-results {
    margin-top: 0.5rem;
    border: 1px solid rgba(200, 16, 46, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.bulk-preview-summary {
    display: flex;
    gap: 0;
    background: rgba(200, 16, 46, 0.04);
    border-bottom: 1px solid rgba(200, 16, 46, 0.08);
}

.bulk-preview-stat {
    flex: 1;
    padding: 0.65rem 0.75rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    border-right: 1px solid rgba(200, 16, 46, 0.08);
}

.bulk-preview-stat:last-child { border-right: none; }

.bulk-preview-stat-num {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.3rem;
    color: #1a1a1a;
}

.bulk-preview-stat.good .bulk-preview-stat-num { color: #16a34a; }
.bulk-preview-stat.warn .bulk-preview-stat-num { color: #d97706; }

.bulk-preview-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
}

.bulk-preview-list {
    max-height: 220px;
    overflow-y: auto;
}

.bulk-preview-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.85rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 0.82rem;
    transition: background 0.1s;
}

.bulk-preview-row:last-child { border-bottom: none; }
.bulk-preview-row:hover { background: rgba(0, 0, 0, 0.015); }

.bulk-preview-row-num {
    font-family: 'SF Mono', monospace;
    font-size: 0.72rem;
    color: #bbb;
    min-width: 22px;
    text-align: right;
}

.bulk-preview-row-email {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
}

.bulk-preview-row-status {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
}

.bulk-preview-row-status.valid {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.bulk-preview-row-status.invalid {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.bulk-preview-row-warns {
    font-size: 0.72rem;
    color: #d97706;
    font-style: italic;
}

/* Modal footer actions */
.bulk-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* ===================================================================
   USERS PANEL — Responsive
   =================================================================== */

@media (max-width: 900px) {
    .users-stats-strip {
        flex-wrap: wrap;
    }
    .users-stat-chip {
        min-width: 100px;
        flex: 1;
    }
    .users-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .users-toolbar-actions {
        margin-left: 0;
        justify-content: stretch;
    }
    .users-toolbar-actions .users-action-btn {
        flex: 1;
        justify-content: center;
    }
    .users-row-actions {
        flex-direction: column;
    }
    .users-cell-identity-text {
        max-width: 180px;
    }
    .bulk-modal-content {
        width: 95%;
    }
}

.restaurants-sync-card {
    margin-bottom: 1rem;
}

.restaurants-sync-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.restaurants-sync-source {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.restaurants-sync-actions {
    margin-top: 1rem;
}

.restaurants-sync-message {
    margin-top: 0.75rem;
}

.restaurants-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.85rem;
}

.restaurants-accordion-node {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.restaurants-accordion-node[open] > .restaurants-accordion-summary {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.restaurants-accordion-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1rem;
    cursor: pointer;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #2f2f2f;
}

.restaurants-accordion-summary::-webkit-details-marker {
    display: none;
}

.restaurants-accordion-summary::before {
    content: '›';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    transform: rotate(0deg);
    transition: transform 0.18s ease;
    color: #C8102E;
    font-size: 1.2rem;
}

.restaurants-accordion-node[open] > .restaurants-accordion-summary::before {
    transform: rotate(90deg);
}

.restaurants-accordion-heading {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.restaurants-accordion-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.restaurants-accordion-responsible {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #555;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.82rem;
}

.restaurants-accordion-count {
    flex: 0 0 auto;
    color: #6f6f6f;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
}

.restaurants-accordion-children {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.7rem 0.8rem 0.8rem;
    background: rgba(0, 0, 0, 0.015);
}

.restaurants-accordion-division,
.restaurants-accordion-area {
    background: #fff;
}

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

.restaurants-accordion-table th,
.restaurants-accordion-table td {
    padding: 0.75rem 0.9rem;
}

.muted-text {
    color: #777 !important;
}

.restaurants-sync-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.restaurants-sync-errors {
    background: rgba(239, 68, 68, 0.07);
    border: 1px solid rgba(239, 68, 68, 0.18);
    border-radius: 12px;
    padding: 0.9rem 1rem;
}

.restaurants-sync-errors h3 {
    margin: 0 0 0.6rem 0;
    font-size: 0.95rem;
    color: #991b1b;
}

.restaurants-sync-errors ul {
    margin: 0;
    padding-left: 1rem;
    max-height: 180px;
    overflow-y: auto;
}

.restaurants-sync-errors li {
    margin-bottom: 0.35rem;
    color: #7f1d1d;
    font-size: 0.85rem;
}


/* =============================================
   TRAINING DASHBOARD — Admin Home Redesign
   ============================================= */

/* Header */
.td-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.td-header-left {
    flex: 1;
    min-width: 200px;
}

.td-title {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.75rem;
    color: #1a1a1a;
    margin: 0 0 0.2rem;
    letter-spacing: -0.02em;
}

.td-subtitle {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #888;
    margin: 0;
}

.td-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.td-period-select {
    padding: 0.55rem 2rem 0.55rem 0.85rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    color: #333;
    background-color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 18px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: all 0.2s ease;
}

.td-period-select:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

.td-refresh-btn {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
}

.td-refresh-btn:hover {
    border-color: #C8102E;
    color: #C8102E;
    background: rgba(200, 16, 46, 0.04);
}

.td-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.td-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1rem;
    color: #888;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── KPI Grid — Primary ── */
.td-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.td-kpi-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 1.35rem 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.td-kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(200, 16, 46, 0.15), transparent);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.td-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(200, 16, 46, 0.08);
    border-color: rgba(200, 16, 46, 0.12);
}

.td-kpi-card:hover::before {
    opacity: 1;
}

.td-kpi-accent {
    border-left: 3px solid #C8102E;
}

.td-kpi-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.td-kpi-icon-wrap svg {
    width: 22px;
    height: 22px;
}

.td-kpi-icon-users {
    background: linear-gradient(135deg, #C8102E, #E8334A);
    color: white;
}

.td-kpi-icon-completion {
    background: linear-gradient(135deg, #1B7340, #28A85C);
    color: white;
}

.td-kpi-icon-score {
    background: linear-gradient(135deg, #1A56DB, #3B82F6);
    color: white;
}

.td-kpi-icon-courses {
    background: linear-gradient(135deg, #9333EA, #A855F7);
    color: white;
}

.td-kpi-data {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.td-kpi-value {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.85rem;
    color: #1a1a1a;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.td-kpi-value small {
    font-size: 0.55em;
    color: #888;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
}

.td-kpi-label {
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    color: #555;
    margin-top: 0.2rem;
    font-weight: 500;
}

.td-kpi-sub {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.15rem;
}

/* ── KPI Grid — Secondary (smaller cards) ── */
.td-kpi-grid-secondary {
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.td-kpi-card-sm {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    transition: all 0.25s ease;
}

.td-kpi-card-sm:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
    border-color: rgba(200, 16, 46, 0.12);
}

.td-kpi-sm-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.td-kpi-sm-icon svg {
    width: 18px;
    height: 18px;
    color: white;
}

.td-icon-launch { background: linear-gradient(135deg, #DC6B16, #F59E0B); }
.td-icon-onboarding { background: linear-gradient(135deg, #0E7490, #22D3EE); }
.td-icon-certs { background: linear-gradient(135deg, #C8102E, #E8334A); }
.td-icon-badges { background: linear-gradient(135deg, #7C3AED, #A78BFA); }
.td-icon-ojt { background: linear-gradient(135deg, #1B7340, #34D399); }
.td-icon-wiki { background: linear-gradient(135deg, #374151, #6B7280); }

.td-kpi-sm-value {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.35rem;
    color: #1a1a1a;
    line-height: 1;
}

.td-kpi-sm-label {
    font-size: 0.72rem;
    color: #777;
    font-weight: 500;
    line-height: 1.2;
}

/* ── Charts Row ── */
.td-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.td-chart-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 1.25rem;
    transition: all 0.25s ease;
}

.td-chart-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.td-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.td-chart-header h3 {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #333;
    margin: 0;
}

.td-chart-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: #888;
    background: rgba(0, 0, 0, 0.04);
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.td-chart-body {
    height: 140px;
    position: relative;
}

.td-chart-body svg {
    display: block;
}

/* ── Bottom Row: Progress + Alerts ── */
.td-bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.td-section-title {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    color: #333;
    margin: 0 0 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Progress card */
.td-progress-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 1.35rem;
}

.td-progress-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.td-progress-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.td-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    color: #555;
}

.td-progress-pct {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.85rem;
    color: #333;
}

.td-progress-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.td-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.td-fill-red { background: linear-gradient(90deg, #C8102E, #E8334A); }
.td-fill-green { background: linear-gradient(90deg, #1B7340, #34D399); }
.td-fill-amber { background: linear-gradient(90deg, #D97706, #FBBF24); }
.td-fill-blue { background: linear-gradient(90deg, #1A56DB, #60A5FA); }

/* Alerts card */
.td-alerts-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 1.35rem;
    max-height: 320px;
    overflow-y: auto;
}

.td-alert-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #C8102E;
    color: white;
    font-size: 0.7rem;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1;
}

.td-alert-banner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    margin-bottom: 0.6rem;
}

.td-alert-banner strong {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
}

.td-alert-error {
    background: rgba(200, 16, 46, 0.06);
    color: #991B1B;
    border: 1px solid rgba(200, 16, 46, 0.12);
}

.td-alert-error svg { color: #C8102E; }

.td-alert-warning {
    background: rgba(217, 119, 6, 0.06);
    color: #92400E;
    border: 1px solid rgba(217, 119, 6, 0.12);
}

.td-alert-warning svg { color: #D97706; }

.td-alert-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.td-alert-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.82rem;
    color: #555;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.4;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.td-alert-item:last-child {
    border-bottom: none;
}

.td-alert-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 0.35rem;
}

.td-alert-item.td-alert-error .td-alert-dot { background: #C8102E; }
.td-alert-item.td-alert-warning .td-alert-dot { background: #D97706; }

.td-alert-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    color: #34D399;
    text-align: center;
}

.td-alert-empty span {
    font-size: 0.85rem;
    color: #888;
}

/* ── Quick Actions ── */
.td-actions-section {
    margin-top: 0.25rem;
}

.td-actions-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
}

.td-action-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 1.15rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: #555;
    text-align: center;
}

.td-action-card svg {
    width: 24px;
    height: 24px;
    color: #C8102E;
    transition: transform 0.2s ease;
}

.td-action-card:hover {
    background: rgba(200, 16, 46, 0.04);
    border-color: rgba(200, 16, 46, 0.15);
    color: #C8102E;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(200, 16, 46, 0.08);
}

.td-action-card:hover svg {
    transform: scale(1.12);
}

/* ── Responsive ── */
@media (max-width: 1280px) {
    .td-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .td-kpi-grid-secondary {
        grid-template-columns: repeat(3, 1fr);
    }
    .td-actions-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 960px) {
    .td-kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .td-kpi-grid-secondary {
        grid-template-columns: repeat(3, 1fr);
    }
    .td-charts-row {
        grid-template-columns: 1fr;
    }
    .td-bottom-row {
        grid-template-columns: 1fr;
    }
    .td-actions-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .td-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .td-kpi-grid {
        grid-template-columns: 1fr;
    }
    .td-kpi-grid-secondary {
        grid-template-columns: repeat(2, 1fr);
    }
    .td-charts-row {
        grid-template-columns: 1fr;
    }
    .td-bottom-row {
        grid-template-columns: 1fr;
    }
    .td-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .td-kpi-value {
        font-size: 1.5rem;
    }
}
