/**
 * Futurekey CRM - Main Stylesheet
 * Global styles, layout, and page-specific styles
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================
   RESET & BASE
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-text-primary);
    background-color: var(--color-bg-body);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   CUSTOM SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
}

ul,
ol {
    list-style: none;
}

button {
    font-family: inherit;
}

/* ============================================
   APP LAYOUT
   ============================================ */
.app {
    display: flex;
    min-height: 100vh;
}

/* Auth Mode - Hide layout */
.app.auth-mode .sidebar,
.app.auth-mode .header {
    display: none;
}

.app.auth-mode .main-content {
    margin-left: 0 !important;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-bg-sidebar);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: var(--z-fixed);
    transition: width var(--transition-normal);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar__header {
    padding: var(--spacing-6);
    border-bottom: 1px solid var(--color-border);
}

.sidebar__logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
}

.sidebar__logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: var(--font-bold);
    font-size: var(--text-lg);
}

.sidebar__logo-text {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--color-text-primary);
}

.sidebar.collapsed .sidebar__logo-text {
    display: none;
}

.sidebar__nav {
    flex: 1;
    padding: var(--spacing-4);
    overflow-y: auto;
}

.sidebar__section {
    margin-bottom: var(--spacing-6);
}

.sidebar__section-title {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: var(--spacing-2) var(--spacing-3);
    margin-bottom: var(--spacing-2);
}

.sidebar.collapsed .sidebar__section-title {
    display: none;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.sidebar__link:hover {
    background: var(--color-bg-card);
    color: var(--color-text-primary);
}

.sidebar__link.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.sidebar__link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar__link-text {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.sidebar.collapsed .sidebar__link-text {
    display: none;
}

/* Cross-entity quick-view links */
.qv-link {
    color: var(--color-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    transition: opacity 0.15s;
    border-radius: 4px;
}
.qv-link:hover {
    opacity: 0.75;
    text-decoration: underline;
}
.qv-link svg {
    flex-shrink: 0;
}

/* Sidebar Groups (Collapsible) */
.sidebar__group {
    margin: 2px 0;
}

.sidebar__group-header {
    position: relative;
    justify-content: flex-start;
}

.sidebar__group-header .sidebar__group-chevron {
    margin-left: auto;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.sidebar__group.collapsed .sidebar__group-header .sidebar__group-chevron {
    transform: rotate(-90deg);
}

.sidebar__group-children {
    overflow: hidden;
    max-height: 800px;
    transition: max-height 0.25s ease;
}

.sidebar__group.collapsed .sidebar__group-children {
    max-height: 0;
}

.sidebar__group-children .sidebar__link {
    padding-left: 44px;
    font-size: 13px;
}

.sidebar.collapsed .sidebar__group-chevron {
    display: none;
}

.sidebar.collapsed .sidebar__group-children .sidebar__link {
    padding-left: var(--spacing-4);
}

.sidebar__footer {
    padding: var(--spacing-4);
    border-top: 1px solid var(--color-border);
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar__user:hover {
    background: var(--color-bg-card);
}

.sidebar__user-info {
    flex: 1;
    min-width: 0;
}

.sidebar__user-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar__user-role {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.sidebar.collapsed .sidebar__user-info {
    display: none;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    transition: margin-left var(--transition-normal);
}

.sidebar.collapsed~.main-content {
    margin-left: var(--sidebar-collapsed);
}

/* ============================================
   HEADER
   ============================================ */
.header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--color-bg-sidebar);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-6);
    z-index: var(--z-sticky);
}

.header__left {
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
}

.header__toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.header__toggle:hover {
    background: var(--color-bg-card);
    color: var(--color-text-primary);
}

.header__title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

.header__right {
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
}

.header__search {
    width: 280px;
}

.global-search-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    padding: var(--spacing-2);
    display: none;
    z-index: var(--z-sticky);
    max-height: 460px;
    overflow-y: auto;
}

.global-search-menu.open {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.global-search-header {
    font-size: 11px;
    color: var(--color-text-muted);
    padding: 6px 10px 4px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 4px;
}

.global-search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.global-search-item:hover {
    background: var(--color-primary-light);
}

.global-search-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.global-search-name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-ref {
    font-size: 11px;
    color: var(--color-text-muted);
    font-family: monospace;
}

.global-search-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.global-search-group + .global-search-group {
    border-top: 1px solid var(--color-border);
    margin-top: 4px;
    padding-top: 4px;
}

.global-search-group-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    padding: 6px 10px 2px;
    font-weight: 600;
}

.global-search-empty {
    padding: 24px 10px;
    color: var(--color-text-muted);
    text-align: center;
    font-size: 13px;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.header__notification {
    position: relative;
}

.header__notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--color-danger);
    border-radius: 50%;
}

.header__theme-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.header__theme-toggle:hover {
    background: var(--color-bg-card);
    color: var(--color-text-primary);
}

/* ============================================
   PAGE CONTAINER
   ============================================ */
.page {
    padding: var(--spacing-6);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-6);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--color-text-primary);
}

.page-subtitle {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-top: var(--spacing-1);
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */
.dashboard-grid {
    display: grid;
    gap: var(--spacing-6);
}

.dashboard-row {
    display: grid;
    gap: var(--spacing-6);
}

/* KPI Row - 4 columns */
.dashboard-row--kpi {
    grid-template-columns: repeat(4, 1fr);
}

/* Main content rows - 2:1 ratio */
.dashboard-row--main {
    grid-template-columns: 2fr 1fr;
}

/* ============================================
   PROPERTIES GRID
   ============================================ */
.properties-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--spacing-6);
}

.properties-filters {
    position: sticky;
    top: calc(var(--header-height) + var(--spacing-6));
    align-self: start;
}

.properties-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-6);
}

.properties-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-6);
}

.properties-count {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.properties-sort {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
}

/* ============================================
   FILTER PANEL
   ============================================ */
.filter-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-6);
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
}

.filter-section__title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-2);
}

.filter-chip {
    padding: var(--spacing-2) var(--spacing-3);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-chip:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.filter-chip.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-text-primary);
}

.filter-range {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.filter-range__separator {
    color: var(--color-text-muted);
}

/* ============================================
   CHART CONTAINER
   ============================================ */
.chart-container {
    position: relative;
    height: 300px;
}

/* ============================================
   ACTIVITY FEED
   ============================================ */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
}

.activity-item {
    display: flex;
    gap: var(--spacing-3);
}

.activity-item__avatar {
    flex-shrink: 0;
}

.activity-item__content {
    flex: 1;
    min-width: 0;
}

.activity-item__text {
    font-size: var(--text-sm);
    color: var(--color-text-primary);
}

.activity-item__text strong {
    font-weight: var(--font-semibold);
}

.activity-item__time {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--spacing-1);
}

/* ============================================
   QUICK LIST (New Properties Widget)
   ============================================ */
.quick-list {
    display: flex;
    flex-direction: column;
}

.quick-list__item {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.quick-list__item:hover {
    background: var(--color-bg-card-hover);
}

.quick-list__image {
    width: 56px;
    height: 42px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.quick-list__info {
    flex: 1;
    min-width: 0;
}

.quick-list__price {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

.quick-list__address {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   MODAL
   ============================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: var(--z-modal-backdrop);
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: var(--z-modal);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-6);
    border-bottom: 1px solid var(--color-border);
}

.modal__title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

.modal__close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.modal__close:hover {
    background: var(--color-bg-card-hover);
    color: var(--color-text-primary);
}

.modal__body {
    padding: var(--spacing-6);
    overflow-y: auto;
    flex: 1;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-3);
    padding: var(--spacing-6);
    border-top: 1px solid var(--color-border);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    bottom: var(--spacing-6);
    right: var(--spacing-6);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
    z-index: var(--z-toast);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-4);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 400px;
    animation: toast-slide-in var(--transition-normal) ease;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast--success {
    border-left: 4px solid var(--color-success);
}

.toast--error {
    border-left: 4px solid var(--color-danger);
}

.toast--warning {
    border-left: 4px solid var(--color-warning);
}

.toast__icon {
    flex-shrink: 0;
}

.toast__content {
    flex: 1;
}

.toast__title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

.toast__message {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-top: var(--spacing-1);
}

.toast__close {
    padding: var(--spacing-1);
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */
@media (max-width: 1280px) {
    .dashboard-row--kpi {
        grid-template-columns: repeat(2, 1fr);
    }

    .properties-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .dashboard-row--main {
        grid-template-columns: 1fr;
    }

    .properties-layout {
        grid-template-columns: 1fr;
    }

    .properties-filters {
        position: static;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .header__search {
        display: none;
    }

    .dashboard-row--kpi {
        grid-template-columns: 1fr;
    }

    .properties-grid {
        grid-template-columns: 1fr;
    }

    .page {
        padding: var(--spacing-4);
        padding-bottom: 80px; /* space for bottom nav if addon active */
    }

    /* Touch-friendly targets */
    .btn, .sidebar__link, .form-select, .form-input {
        min-height: 44px;
    }

    /* Safe area for notched phones */
    .header {
        padding-top: env(safe-area-inset-top);
    }

    .sidebar {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* PWA standalone mode */
    @media (display-mode: standalone) {
        .header {
            padding-top: calc(env(safe-area-inset-top) + 8px);
        }
    }

    /* Better modal sizing on mobile */
    .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 90vh !important;
        margin: 5vh auto;
    }

    /* Filters stack on mobile */
    .filters-row {
        flex-direction: column;
        gap: var(--spacing-2);
    }

    .filters-row > * {
        width: 100%;
    }

    /* Page header responsive */
    .page-header {
        flex-direction: column;
        gap: var(--spacing-2);
        align-items: flex-start;
    }

    .page-header .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--color-text-muted);
}

.text-primary {
    color: var(--color-primary);
}

.text-success {
    color: var(--color-success);
}

.text-danger {
    color: var(--color-danger);
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: var(--spacing-2);
}

.gap-3 {
    gap: var(--spacing-3);
}

.gap-4 {
    gap: var(--spacing-4);
}

.mt-4 {
    margin-top: var(--spacing-4);
}

.mb-4 {
    margin-bottom: var(--spacing-4);
}

.ml-auto {
    margin-left: auto;
}

.w-full {
    width: 100%;
}

.hidden {
    display: none !important;
}

/* ============================================
   PDF BUILDER PAGE
   ============================================ */
.pdf-builder-page { max-width: 100%; }

.pb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.pb-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.pb-title svg { color: var(--color-primary); }

.pb-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 20px;
}
.pb-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.pb-tab:hover { color: var(--color-text); }
.pb-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Documents Layout */
.pb-docs-layout {
    display: flex;
    gap: 20px;
    min-height: 400px;
}
.pb-folders-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}
.pb-folders-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}
.pb-add-folder-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
}
.pb-add-folder-btn:hover { color: var(--color-primary); background: var(--color-bg-hover); }

.pb-folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.15s;
}
.pb-folder-item:hover { background: var(--color-bg-hover); }
.pb-folder-item.active {
    background: var(--color-primary-bg, rgba(127, 86, 217, 0.1));
    color: var(--color-primary);
}
.pb-folder-item svg { flex-shrink: 0; }
.pb-folder-item span:first-of-type { flex: 1; }
.pb-folder-count {
    font-size: 11px;
    color: var(--color-text-muted);
    background: var(--color-bg-body);
    padding: 1px 6px;
    border-radius: 10px;
}

.pb-docs-main { flex: 1; min-width: 0; }

.pb-docs-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pb-doc-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: border-color 0.15s;
}
.pb-doc-card:hover { border-color: var(--color-primary); }
.pb-doc-icon { color: var(--color-primary); flex-shrink: 0; }
.pb-doc-info { flex: 1; min-width: 0; }
.pb-doc-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pb-doc-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}
.pb-doc-badge {
    background: var(--color-primary-bg, rgba(127, 86, 217, 0.1));
    color: var(--color-primary);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
}
.pb-doc-actions { display: flex; gap: 4px; flex-shrink: 0; }
.pb-doc-action-btn {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.15s;
}
.pb-doc-action-btn:hover { color: var(--color-text); border-color: var(--color-text-muted); }
.pb-delete-doc-btn:hover { color: #ef4444; border-color: #ef4444; }

/* Empty state */
.pb-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    gap: 12px;
}
.pb-empty p { color: var(--color-text-muted); font-size: 13px; }

/* Templates Grid */
.pb-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.pb-template-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.pb-template-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.pb-template-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}
.pb-template-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
}
.pb-template-type {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}
.pb-template-actions { display: flex; align-items: center; justify-content: center; gap: 8px; }
.pb-system-badge {
    font-size: 10px;
    color: var(--color-text-muted);
    background: var(--color-bg-body);
    padding: 3px 8px;
    border-radius: 4px;
}

/* Letterheads */
.pb-letterheads-header { margin-bottom: 16px; }
.pb-letterheads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.pb-letterhead-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 16px;
}
.pb-lh-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 12px;
}
.pb-lh-previews { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.pb-lh-preview-item { }
.pb-lh-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}
.pb-lh-preview-item img {
    width: 100%;
    max-height: 60px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background: #fff;
}
.pb-lh-empty {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--color-text-muted);
    border: 1px dashed var(--color-border);
    border-radius: 4px;
}
.pb-lh-actions { text-align: right; }

/* Modal */
.pb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}
.pb-modal {
    background: var(--color-bg-card);
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}
.pb-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}
.pb-modal-header h3 { font-size: 16px; color: var(--color-text); }
.pb-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--color-text-muted);
    cursor: pointer;
    line-height: 1;
}
.pb-modal-close:hover { color: var(--color-text); }
.pb-modal-body { padding: 20px; }
.pb-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
}

/* File drop */
.pb-file-drop {
    border: 2px dashed var(--color-border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}
.pb-file-drop:hover, .pb-file-drop.dragover { border-color: var(--color-primary); }
.pb-file-drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--color-text-muted);
    font-size: 12px;
}

/* Template Selector */
.pb-template-selector-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pb-template-select-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.pb-template-select-item:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-bg, rgba(127, 86, 217, 0.05));
}
.pb-tsi-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pb-tsi-name { font-size: 13px; font-weight: 600; color: var(--color-text); }
.pb-tsi-type { font-size: 11px; color: var(--color-text-muted); text-transform: capitalize; }

/* Editor */
.pb-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.pb-editor-title-wrap { flex: 1; min-width: 200px; }
.pb-editor-title-input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}
.pb-editor-title-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-bg-card);
}
.pb-editor-toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.pb-editor-body {
    display: flex;
    gap: 20px;
    min-height: 500px;
}
.pb-editor-fields {
    width: 380px;
    flex-shrink: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow-y: auto;
    max-height: calc(100vh - 220px);
}
.pb-editor-fields-inner { padding: 16px; }
.pb-field-group { margin-bottom: 14px; }
.pb-field-group .form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.pb-editor-preview {
    flex: 1;
    min-width: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}
.pb-preview-frame-wrap {
    width: 100%;
    height: 100%;
    min-height: 500px;
    position: relative;
}
.pb-preview-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.pb-preview-placeholder p { color: var(--color-text-muted); font-size: 13px; }
.pb-preview-iframe {
    width: 100%;
    height: 100%;
    min-height: 500px;
    border: none;
    background: #fff;
}

/* Items table in editor */
.pb-items-list { display: flex; flex-direction: column; gap: 6px; }
.pb-item-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.pb-item-row .form-input { font-size: 12px; padding: 6px 8px; }
.pb-item-row .pb-item-desc { flex: 1; }
.pb-remove-item-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
}
.pb-remove-item-btn:hover { color: #ef4444; }

/* Responsive */
@media (max-width: 768px) {
    .pb-docs-layout { flex-direction: column; }
    .pb-folders-sidebar { width: 100%; }
    .pb-folder-list { display: flex; overflow-x: auto; gap: 0; }
    .pb-folder-item { white-space: nowrap; }
    .pb-editor-body { flex-direction: column; }
    .pb-editor-fields { width: 100%; max-height: none; }
    .pb-editor-toolbar { flex-direction: column; align-items: stretch; }
    .pb-editor-toolbar-right { justify-content: flex-end; }
    .pb-templates-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ============================================
   SALES OFFER MODAL
   ============================================ */
.so-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--color-bg-body);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.so-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Toolbar */
.so-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-card);
    flex-shrink: 0;
    gap: 12px;
    flex-wrap: wrap;
}
.so-toolbar-left { display: flex; align-items: center; gap: 12px; }
.so-toolbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}
.so-toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Body */
.so-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Form Panel */
.so-form-panel {
    width: 420px;
    flex-shrink: 0;
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    background: var(--color-bg-card);
}
.so-form-inner { padding: 16px 20px; }

/* Sections */
.so-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}
.so-section:last-child { border-bottom: none; }
.so-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}
.so-section-header svg { flex-shrink: 0; }

/* Fields Grid */
.so-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.so-field { display: flex; flex-direction: column; gap: 3px; }
.so-field label {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.so-field .form-input { font-size: 12px; padding: 6px 8px; }
.so-field-full { grid-column: 1 / -1; }
.so-textarea { resize: vertical; min-height: 60px; font-size: 12px !important; }

/* Images Grid */
.so-images-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.so-image-item {
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.so-image-item.selected { border-color: var(--color-primary); }
.so-image-item img {
    width: 100%;
    height: 60px;
    object-fit: cover;
    display: block;
}
.so-image-item input[type="checkbox"] { display: none; }
.so-image-check {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.so-image-item.selected .so-image-check { display: flex; }

/* Preview Panel */
.so-preview-panel {
    flex: 1;
    min-width: 0;
    position: relative;
    background: #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
}
.so-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}
.so-preview-placeholder p { color: var(--color-text-muted); font-size: 13px; }
.so-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}
.so-preview-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.15);
    z-index: 5;
    pointer-events: none;
    backdrop-filter: blur(1px);
}

/* Responsive */
@media (max-width: 900px) {
    .so-body { flex-direction: column; }
    .so-form-panel { width: 100%; max-height: 50vh; border-right: none; border-bottom: 1px solid var(--color-border); }
    .so-toolbar-title { max-width: 200px; }
    .so-images-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================
   Permissions Page
   ============================================ */
/* ========== Permissions Page v2 ========== */
.perm-page { padding: 0 !important; display: flex; flex-direction: column; height: 100%; }
.perm-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Sidebar */
.perm-sidebar {
    width: 320px;
    min-width: 320px;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
}
.perm-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px 14px;
}
.perm-sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}
.perm-user-count {
    font-size: 11px;
    font-weight: 600;
    background: var(--color-primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}
.perm-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 12px 12px;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-muted);
    background: var(--color-bg-elevated, var(--color-bg));
    transition: border-color 0.15s;
}
.perm-search:focus-within {
    border-color: var(--color-primary);
}
.perm-search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--color-text);
    outline: none;
}
.perm-search-input::placeholder { color: var(--color-text-muted); }
.perm-user-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 8px;
}
.perm-user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 2px;
    transition: background 0.15s;
}
.perm-user-item:hover { background: var(--color-bg-hover); }
.perm-user-item.active {
    background: var(--color-primary-alpha, rgba(99,102,241,0.1));
}
.perm-user-item.perm-user-inactive { opacity: 0.5; }
.perm-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}
.perm-user-info { flex: 1; min-width: 0; }
.perm-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}
.perm-inactive-tag {
    font-size: 9px;
    font-weight: 600;
    color: #ef4444;
    background: rgba(239,68,68,0.1);
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.perm-user-meta {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.perm-role-pill {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.perm-no-users {
    padding: 32px 16px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
}

/* Main Panel */
.perm-main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    background: var(--color-bg-elevated, var(--color-bg));
}
.perm-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
    padding: 40px;
}
.perm-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--color-bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}
.perm-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}
.perm-empty-desc {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* Panel Header */
.perm-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    position: sticky;
    top: 0;
    z-index: 2;
}
.perm-panel-user {
    display: flex;
    align-items: center;
    gap: 14px;
}
.perm-panel-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.perm-panel-info { display: flex; flex-direction: column; gap: 4px; }
.perm-panel-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}
.perm-panel-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.perm-panel-email {
    font-size: 12px;
    color: var(--color-text-muted);
}
.perm-override-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-primary);
    background: var(--color-primary-alpha, rgba(99,102,241,0.1));
    padding: 2px 8px;
    border-radius: 4px;
}
.perm-panel-actions {
    display: flex;
    gap: 8px;
}
.perm-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-bg-hover);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.perm-reset-btn:hover {
    background: var(--color-bg);
    border-color: var(--color-text-muted);
}
.perm-reset-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Super admin notice */
.perm-super-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 24px;
    padding: 16px 20px;
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.25);
    border-radius: 10px;
    color: var(--color-text);
    font-size: 13px;
    line-height: 1.5;
}
.perm-super-notice svg { flex-shrink: 0; margin-top: 2px; color: #f59e0b; }
.perm-super-notice strong { display: block; margin-bottom: 2px; }

/* Module Groups */
.perm-modules { padding: 16px 24px 24px; }
.perm-module {
    margin-bottom: 12px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
}
.perm-module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}
.perm-module-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.perm-module-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.perm-module-header svg { color: var(--color-text-muted); }
.perm-module-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg-hover);
    padding: 3px 10px;
    border-radius: 10px;
}
.perm-module-body { }

/* Permission Rows */
.perm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.1s;
}
.perm-row:last-child { border-bottom: none; }
.perm-row:hover { background: var(--color-bg-hover); }
.perm-row.perm-row-override { background: rgba(99,102,241,0.04); }
.perm-row-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.perm-row-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
}
.perm-row-min {
    font-size: 10px;
    color: var(--color-text-muted);
    background: var(--color-bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}
.perm-row-custom {
    font-size: 9px;
    font-weight: 700;
    color: var(--color-primary);
    background: var(--color-primary-alpha, rgba(99,102,241,0.1));
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Toggle Switch v2 */
.perm-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}
.perm-switch input { display: none; }
.perm-switch-track {
    position: relative;
    width: 38px;
    height: 22px;
    background: var(--color-border);
    border-radius: 11px;
    transition: background 0.2s;
}
.perm-switch-track::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.perm-switch input:checked + .perm-switch-track {
    background: #22c55e;
}
.perm-switch input:checked + .perm-switch-track::before {
    transform: translateX(16px);
}
.perm-switch-label {
    font-size: 12px;
    font-weight: 600;
    min-width: 24px;
    color: var(--color-text-muted);
}
.perm-switch input:checked ~ .perm-switch-label {
    color: #22c55e;
}

/* Spin animation for reset button */
@keyframes perm-spin {
    to { transform: rotate(360deg); }
}
.perm-spin { animation: perm-spin 0.8s linear infinite; }

/* Responsive */
@media (max-width: 900px) {
    .perm-layout { flex-direction: column; }
    .perm-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 280px;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    .perm-modules { padding: 12px 12px 16px; }
    .perm-panel-header { padding: 12px 16px; }
}

/* ============================================
   COMMUNICATIONS PAGE
   ============================================ */
/* Compact stats row */
.comm-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}
.comm-stat {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    min-width: 0;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.comm-stat:hover {
    border-color: var(--color-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.comm-stat__icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 14px;
    flex-shrink: 0;
}
.comm-stat__icon--primary { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.comm-stat__icon--success { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.comm-stat__icon--warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.comm-stat__value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1;
}
.comm-stat__label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.comm-timeline {
    position: relative;
}
.comm-timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}
.comm-timeline-item:hover .timeline__content {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.comm-entity-link {
    color: var(--color-primary);
    font-weight: 500;
    transition: opacity 0.2s;
}
.comm-entity-link:hover {
    opacity: 0.85;
    text-decoration: underline;
}

/* ============================================
   ROLE-BASED UI: Hide delete for non-admin
   ============================================ */
body:not([data-user-role="admin"]):not([data-user-role="super_admin"]) .btn-delete,
body:not([data-user-role="admin"]):not([data-user-role="super_admin"]) .delete-btn,
body:not([data-user-role="admin"]):not([data-user-role="super_admin"]) [data-action="delete"],
body:not([data-user-role="admin"]):not([data-user-role="super_admin"]) .action-delete {
    display: none !important;
}
