/* ===== CSS VARIABLES ===== */
:root {
    --bg-body: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-muted: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --primary: #7c3aed;
    --accent: #7c3aed;
    --bg-main: var(--bg-body);
    --primary-light: #8b5cf6;
    --primary-dark: #6d28d9;
    --primary-glow: rgba(124, 58, 237, 0.15);
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.03);
    --shadow-xl: 0 20px 40px -5px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --input-radius: 12px;
    --input-bg: var(--bg-card);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --bg-muted: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #1e293b;
    --primary-glow: rgba(124, 58, 237, 0.25);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 40px -5px rgba(0,0,0,0.6);
}

/* ===== RESET & BASE ===== */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
    transition: var(--transition);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

::-webkit-scrollbar { 
    width: 6px; 
    height: 6px; 
}
::-webkit-scrollbar-track { 
    background: transparent; 
}
::-webkit-scrollbar-thumb { 
    background: var(--border-color); 
    border-radius: 10px; 
}
::-webkit-scrollbar-thumb:hover { 
    background: var(--text-muted); 
}

/* ===== FORM CONTROLS (global — rounded, modern) ===== */
textarea,
select,
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="image"]) {
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    padding: 11px 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

select {
    cursor: pointer;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    appearance: none;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

textarea:focus,
select:focus,
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="image"]):focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

.topbar-search input {
    border: none;
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

.topbar-search input:focus {
    border: none;
    box-shadow: none;
}

input[type="color"] {
    padding: 4px;
    min-height: 40px;
    cursor: pointer;
}

/* ===== APP SHELL (sidebar + main row) ===== */
#appShell {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}
/* ===== SIDEBAR ===== */
.sidebar {
    width: 260px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
    overflow: hidden;
    padding: 0 16px 20px;
    position: relative;
    z-index: 10;
}

.sidebar-brand {
    padding: 24px 12px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.5px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    color: var(--text-primary);
}

.sidebar-brand .logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 700;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.sidebar-brand .logo-img {
    height: 42px;
    width: auto;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand .logo-text {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.sidebar-brand .logo-text span:first-child {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.sidebar-brand .logo-text span:last-child {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-nav .section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 16px 12px 8px;
    user-select: none;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    text-decoration: none;
}

.sidebar-nav a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateX(4px);
}

.sidebar-nav a.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
    transform: translateX(0);
}

.sidebar-nav a.active:hover {
    background: var(--primary-dark);
}

.sidebar-nav a .icon { 
    width: 20px; 
    text-align: center; 
    font-size: 16px; 
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-nav a .icon i {
    font-size: 16px;
    width: 20px;
    line-height: 1;
}

.sidebar-nav a .badge {
    margin-left: auto;
    background: var(--bg-hover);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
}

.sidebar-nav a.active .badge { 
    background: rgba(255,255,255,0.2); 
    color: white; 
}

.sidebar-nav a .indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-left: auto;
}
.sidebar-nav a .indicator.online { background: var(--success); }
.sidebar-nav a .indicator.offline { background: var(--text-muted); }
.sidebar-nav a .indicator.warning { background: var(--warning); }

/* ===== MAIN CONTENT ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-body);
}

/* ===== TOP NAV ===== */
.topbar {
    height: 72px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    flex-shrink: 0;
    transition: var(--transition);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-left .breadcrumb {
    font-size: 14px;
    color: var(--text-muted);
}
.topbar-left .breadcrumb span {
    color: var(--text-primary);
    font-weight: 500;
}

.topbar-search {
    display: flex;
    align-items: center;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    padding: 8px 16px;
    gap: 10px;
    flex: 1;
    max-width: 440px;
    transition: var(--transition);
}

.topbar-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg-card);
}

.topbar-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
    width: 100%;
    font-family: inherit;
}

.topbar-search input::placeholder { 
    color: var(--text-muted); 
}

.topbar-search .search-icon {
    color: var(--text-muted);
    font-size: 16px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.topbar-search .search-icon i {
    font-size: 14px;
}

.topbar-search .shortcut {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-actions button:hover { 
    background: var(--bg-hover); 
    color: var(--text-primary); 
}

.topbar-actions button i {
    font-size: 16px;
    line-height: 1;
}

.topbar-actions .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-sidebar);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

.topbar-actions .user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border-radius: 30px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.topbar-actions .user-menu:hover { 
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.topbar-actions .user-menu .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    flex-shrink: 0;
}

.topbar-actions .user-menu .avatar.has-photo,
.sidebar-user .avatar.has-photo {
    background: var(--surface-elevated, #e2e8f0);
}

.topbar-actions .user-menu .avatar,
.sidebar-user .avatar {
    position: relative;
}

.avatar img.avatar-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* —— Profile photo settings (MC + Portal) —— */
.profile-photo-card {
    margin-top: 8px;
}

.profile-photo-layout {
    display: grid;
    grid-template-columns: minmax(140px, 200px) minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

@media (max-width: 720px) {
    .profile-photo-layout {
        grid-template-columns: 1fr;
    }
}

.profile-photo-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}

.profile-photo-preview-stack {
    position: relative;
    width: 112px;
    height: 112px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-photo-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    opacity: 0.2;
    pointer-events: none;
}

.profile-photo-preview {
    position: relative;
    z-index: 1;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--primary), var(--primary-light));
    box-shadow:
        0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent),
        0 0 0 4px var(--surface-card, #fff),
        0 0 0 5px color-mix(in srgb, var(--primary) 12%, transparent);
    overflow: hidden;
}

.profile-photo-initial {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 34px;
    letter-spacing: -0.02em;
    user-select: none;
    z-index: 1;
}

.profile-photo-initial[hidden] {
    display: none !important;
}

.profile-photo-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 2;
}

.profile-photo-img[hidden] {
    display: none !important;
}

.profile-photo-preview.is-photo {
    background: var(--surface-elevated, #e2e8f0);
}

.profile-photo-caption {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-muted);
    max-width: 160px;
}

.profile-photo-controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.profile-photo-dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 16px;
    border: 1.5px dashed color-mix(in srgb, var(--primary) 35%, var(--border-light));
    border-radius: 14px;
    background: color-mix(in srgb, var(--primary) 4%, var(--surface-card, #fff));
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    text-align: center;
    overflow: hidden;
}

.profile-photo-dropzone:hover,
.profile-photo-dropzone.drag-over {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, var(--surface-card, #fff));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

.profile-photo-dropzone.has-file {
    border-style: solid;
    border-color: color-mix(in srgb, var(--primary) 45%, transparent);
}

.profile-photo-file {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.profile-photo-dropzone-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--primary);
    font-size: 18px;
}

.profile-photo-dropzone-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-photo-dropzone-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.profile-photo-dropzone-file {
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-photo-url-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-photo-url-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, var(--text-muted));
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.profile-photo-url-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: var(--surface-card, #fff);
    font-size: 14px;
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.profile-photo-url-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

.profile-photo-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.profile-photo-meta {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
    display: grid;
    gap: 10px;
}

.profile-photo-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--surface-muted, color-mix(in srgb, var(--border-light) 40%, transparent));
}

.profile-photo-meta-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.profile-photo-meta-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
}

.profile-card-account > h4 {
    margin-bottom: 4px;
}

.topbar-actions .user-menu .user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.topbar-actions .user-menu .user-info .name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.topbar-actions .user-menu .user-info .role {
    font-size: 11px;
    color: var(--text-muted);
}

.topbar-actions .user-menu .chevron {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* ===== PAGE CONTENT ===== */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    transition: var(--transition);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.page-header .title-section {
    flex: 1 1 260px;
    min-width: 0;
}

.page-header .title-section h1 { 
    font-size: 28px; 
    font-weight: 700; 
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-header .title-section .subtitle { 
    color: var(--text-secondary); 
    font-size: 14px; 
    margin-top: 4px; 
    font-weight: 400;
    -webkit-text-fill-color: var(--text-secondary);
}

.page-header .actions { 
    display: flex; 
    gap: 12px; 
    align-items: center;
    flex-wrap: wrap;
    max-width: 100%;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ===== KPI CARDS ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    opacity: 0;
    transition: var(--transition);
}

.kpi-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: var(--border-color);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-card .header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.kpi-card .label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-card .value {
    font-size: clamp(22px, 4vw, 32px);
    font-weight: 800;
    margin: 8px 0 4px;
    letter-spacing: -0.5px;
    line-height: 1.15;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    word-break: break-word;
}

.kpi-card .trend {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.kpi-card .trend.up { color: var(--success); }
.kpi-card .trend.down { color: var(--danger); }
.kpi-card .trend.neutral { color: var(--text-muted); }

.kpi-card .icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--primary-glow);
    color: var(--primary);
}

.kpi-card .icon-wrapper.green { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.kpi-card .icon-wrapper.yellow { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.kpi-card .icon-wrapper.red { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.kpi-card .icon-wrapper.blue { background: rgba(59, 130, 246, 0.1); color: var(--info); }

.kpi-card .sparkline {
    height: 40px;
    margin-top: 16px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
}

.kpi-card .sparkline .bar {
    flex: 1;
    background: var(--primary-light);
    border-radius: 2px;
    opacity: 0.4;
    transition: var(--transition);
}

.kpi-card .sparkline .bar:hover { opacity: 1; }
.kpi-card .sparkline .bar.high { background: var(--primary); opacity: 0.8; }
.kpi-card .sparkline .bar.high:hover { opacity: 1; }

/* ===== CHARTS SECTION ===== */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.chart-card:hover {
    box-shadow: var(--shadow-md);
}

.chart-card h3 { 
    font-size: 16px; 
    font-weight: 600; 
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-card h3 .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
}

.chart-card .chart-container {
    height: 220px;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: 12px 0;
    gap: 8px;
    position: relative;
}

.chart-card .chart-container .col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100%;
    justify-content: flex-end;
}

.chart-card .chart-container .col .bar-wrapper {
    width: 100%;
    max-width: 40px;
    height: 100%;
    display: flex;
    align-items: flex-end;
    position: relative;
}

.chart-card .chart-container .col .bar {
    width: 100%;
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
    border-radius: 4px 4px 0 0;
    min-height: 8px;
    transition: var(--transition);
    position: relative;
}

.chart-card .chart-container .col .bar:hover {
    opacity: 0.8;
    transform: scaleY(1.02);
    transform-origin: bottom;
}

.chart-card .chart-container .col .bar .tooltip {
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    opacity: 0;
    transition: var(--transition);
    white-space: nowrap;
    box-shadow: var(--shadow);
}

.chart-card .chart-container .col .bar:hover .tooltip {
    opacity: 1;
}

.chart-card .chart-container .col .label { 
    font-size: 12px; 
    color: var(--text-muted);
    font-weight: 500;
}

/* Donut Chart */
.donut-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 200px;
    justify-content: center;
}

.donut-container {
    position: relative;
    width: 160px;
    height: 160px;
}

.donut-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        var(--primary) 0% 25%,
        var(--success) 25% 45%,
        var(--warning) 45% 65%,
        var(--danger) 65% 80%,
        var(--info) 80% 90%,
        var(--text-muted) 90% 100%
    );
    position: relative;
    transition: var(--transition);
}

.donut-ring::after {
    content: '';
    position: absolute;
    top: 35px;
    left: 35px;
    width: 90px;
    height: 90px;
    background: var(--bg-card);
    border-radius: 50%;
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1;
}

.donut-center .number {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.donut-center .label {
    font-size: 12px;
    color: var(--text-muted);
}

.industry-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 16px;
    justify-content: center;
}

.industry-legend .item {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.industry-legend .dot { 
    width: 10px; 
    height: 10px; 
    border-radius: 50%; 
    display: inline-block; 
    flex-shrink: 0;
}

/* ===== RECENT ACTIVITY ===== */
.activity-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.activity-section .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.activity-section .header h3 { 
    font-size: 16px; 
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.activity-section .header .live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--success);
}

.activity-section .header .live-indicator .pulse {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: default;
}

.activity-item:hover {
    background: var(--bg-hover);
}

.activity-item .icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.activity-item .icon-wrapper.green { background: var(--success-light); color: var(--success); }
.activity-item .icon-wrapper.blue { background: var(--info-light); color: var(--info); }
.activity-item .icon-wrapper.yellow { background: var(--warning-light); color: var(--warning); }
.activity-item .icon-wrapper.red { background: var(--danger-light); color: var(--danger); }
.activity-item .icon-wrapper.grey { background: var(--bg-hover); color: var(--text-muted); }

.activity-item .content { flex: 1; }
.activity-item .content .text { 
    font-size: 14px; 
    color: var(--text-primary);
    line-height: 1.5;
}

.activity-item .content .text strong { 
    font-weight: 600;
    color: var(--text-primary);
}

.activity-item .content .time { 
    font-size: 12px; 
    color: var(--text-muted); 
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.activity-item .content .time .badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--bg-hover);
    color: var(--text-muted);
}

/* ===== ORGANIZATIONS TABLE ===== */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: var(--shadow);
}

.org-table td,
.org-table th {
    vertical-align: top;
}

.org-table td .panel-hint {
    display: block;
    margin-top: 4px;
    word-break: break-word;
}

.table-toolbar {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.table-toolbar .search-wrapper {
    position: relative;
    flex: 1;
    max-width: 320px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    background: var(--bg-body);
    transition: var(--transition);
}

.table-toolbar .search-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Match global form-control specificity so left padding / transparent chrome actually wins. */
.table-toolbar .search-wrapper input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="image"]) {
    width: 100%;
    min-width: 0;
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    padding: 10px 0;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
}

.table-toolbar .search-wrapper input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="image"]):focus {
    outline: none;
    border: none;
    box-shadow: none;
}

.table-toolbar .search-wrapper .search-icon {
    position: static;
    transform: none;
    flex-shrink: 0;
    color: var(--text-muted);
    pointer-events: none;
    line-height: 1;
    display: flex;
    align-items: center;
}

.table-toolbar .filter-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.table-toolbar .filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.table-toolbar .filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.org-table {
    width: 100%;
    border-collapse: collapse;
}

.org-table th {
    background: var(--bg-muted);
    padding: 14px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    user-select: none;
}

.org-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.org-table tr:last-child td {
    border-bottom: none;
}

.org-table tbody tr {
    transition: var(--transition);
    cursor: pointer;
}

.org-table tbody tr:hover td {
    background: var(--bg-hover);
}

.org-table .org-name {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.org-table .org-name .avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.org-table .org-name .avatar.cm { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.org-table .org-name .avatar.nf { background: linear-gradient(135deg, #10b981, #059669); }
.org-table .org-name .avatar.rc { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.org-table .org-name .avatar.num { background: linear-gradient(135deg, #f59e0b, #d97706); }
.org-table .org-name .avatar.ob { background: linear-gradient(135deg, #ef4444, #dc2626); }

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.status-badge.active { background: var(--success-light); color: var(--success); }
.status-badge.inactive { background: var(--bg-hover); color: var(--text-muted); }
.status-badge.suspended { background: var(--danger-light); color: var(--danger); }
.status-badge.pending { background: var(--warning-light); color: var(--warning); }
.status-badge.trial { background: var(--info-light); color: var(--info); }

.plan-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.plan-badge.starter { background: var(--bg-hover); color: var(--text-secondary); }
.plan-badge.professional { background: var(--success-light); color: var(--success); }
.plan-badge.business { background: var(--info-light); color: var(--info); }
.plan-badge.enterprise { background: var(--primary-glow); color: var(--primary); }
.plan-badge.custom { background: var(--warning-light); color: var(--warning); }

.table-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.table-footer .info {
    font-size: 13px;
    color: var(--text-muted);
}

.table-footer .pagination {
    display: flex;
    gap: 4px;
}

.table-footer .pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.table-footer .pagination button:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.table-footer .pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.table-footer .pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== ORGANIZATION PROFILE (Slide-over) ===== */
.slide-over {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 720px;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    z-index: 100;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.slide-over.open {
    right: 0;
}

.slide-over .slide-header {
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-shrink: 0;
}

.slide-over .slide-header .title-group h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.slide-over .slide-header .title-group .sub {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 2px;
}

.slide-over .slide-header .close-btn {
    padding: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 20px;
}

.slide-over .slide-header .close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.slide-over .slide-tabs {
    display: flex;
    gap: 4px;
    padding: 0 28px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow-x: auto;
}

.slide-over .slide-tabs .tab {
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.slide-over .slide-tabs .tab:hover {
    color: var(--text-primary);
}

.slide-over .slide-tabs .tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.slide-over .slide-body {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
}

.slide-over .slide-body .tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.slide-over .slide-body .tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Profile content */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 24px;
}

.profile-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
}

.profile-card h4 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.profile-card .info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.profile-card .info-row:last-child { border-bottom: none; }
.profile-card .info-row .label { color: var(--text-muted); }
.profile-card .info-row .value { font-weight: 500; color: var(--text-primary); }

.profile-card .status-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

/* ===== ORGANIZATION WIZARD ===== */
.wizard-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.wizard-overlay.open {
    display: flex;
}

.wizard-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.wizard-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.wizard-header h2 {
    font-size: 22px;
    font-weight: 700;
}

.wizard-header .step-indicator {
    font-size: 14px;
    color: var(--text-muted);
}

.wizard-header .step-indicator span {
    color: var(--text-primary);
    font-weight: 600;
}

.wizard-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.wizard-body .form-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.wizard-body .form-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.wizard-body .form-section h4 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wizard-body .form-group {
    margin-bottom: 16px;
}

.wizard-body .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.wizard-body .form-group .label-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 12px;
}

.wizard-body .form-group input,
.wizard-body .form-group select,
.wizard-body .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.wizard-body .form-group input:focus,
.wizard-body .form-group select:focus,
.wizard-body .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.wizard-body .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.wizard-body .input-with-action {
    display: flex;
    gap: 8px;
}

.wizard-body .input-with-action input {
    flex: 1;
}

.company-form-modal {
    max-width: 720px;
}

.wizard-step {
    display: none;
    animation: fadeIn 0.3s ease;
}

.wizard-step.active {
    display: block;
}

.wizard-step h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.wizard-step .step-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.wizard-step .form-group {
    margin-bottom: 20px;
}

.wizard-step .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.wizard-step .form-group input,
.wizard-step .form-group select,
.wizard-step .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.wizard-step .form-group input:focus,
.wizard-step .form-group select:focus,
.wizard-step .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.wizard-step .form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.wizard-step .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.wizard-step .plan-cards {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.wizard-step .plan-card {
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.wizard-step .plan-card:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.wizard-step .plan-card.selected {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.wizard-step .plan-card .plan-name {
    font-weight: 600;
    font-size: 16px;
}

.wizard-step .plan-card .plan-price {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.wizard-step .plan-card .plan-features {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.wizard-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.wizard-footer .btn-group {
    display: flex;
    gap: 12px;
}

/* ===== DEVELOPER TOOLS ===== */
.dev-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.dev-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.dev-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dev-card .env-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.dev-card .env-badge.development { background: var(--warning-light); color: var(--warning); }
.dev-card .env-badge.staging { background: var(--info-light); color: var(--info); }
.dev-card .env-badge.production { background: var(--success-light); color: var(--success); }

.dev-card .feature-flag {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.dev-card .feature-flag:last-child {
    border-bottom: none;
}

.dev-card .feature-flag .flag-name {
    font-weight: 500;
}

.dev-card .feature-flag .flag-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.toggle-switch {
    width: 40px;
    height: 22px;
    background: var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    flex-shrink: 0;
}

.toggle-switch.on {
    background: var(--primary);
}

.toggle-switch .toggle-knob {
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.toggle-switch.on .toggle-knob {
    left: 20px;
}

.dev-card .api-key {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 13px;
    border: 1px solid var(--border-color);
}

.dev-card .api-key .key-value {
    flex: 1;
    color: var(--text-secondary);
}

.dev-card .api-key .copy-btn {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-card);
    cursor: pointer;
    transition: var(--transition);
    font-size: 12px;
}

.dev-card .api-key .copy-btn:hover {
    background: var(--bg-hover);
}

.webhook-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.webhook-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.webhook-item .webhook-url {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
}

.webhook-item .webhook-status {
    font-size: 12px;
    font-weight: 500;
}

.webhook-item .webhook-status.success { color: var(--success); }
.webhook-item .webhook-status.failed { color: var(--danger); }

.log-viewer {
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.log-viewer .log-line {
    padding: 2px 0;
    display: flex;
    gap: 12px;
}

.log-viewer .log-line .log-time {
    color: var(--text-muted);
}

.log-viewer .log-line .log-level {
    font-weight: 600;
}

.log-viewer .log-line .log-level.info { color: var(--info); }
.log-viewer .log-line .log-level.error { color: var(--danger); }
.log-viewer .log-line .log-level.warn { color: var(--warning); }
.log-viewer .log-line .log-level.debug { color: var(--text-muted); }

.log-viewer .log-line .log-msg {
    color: var(--text-secondary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
    .dev-grid { grid-template-columns: 1fr; }
    .wizard-step .plan-cards { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { 
        width: 72px; 
        padding: 0 8px; 
    }
    .sidebar .sidebar-brand span:not(.logo-icon), 
    .sidebar-nav a span:not(.icon), 
    .sidebar-nav .section-label, 
    .sidebar-nav a .badge,
    .sidebar-nav a .indicator,
    .sidebar-brand .logo-text { 
        display: none; 
    }
    .sidebar-brand { 
        justify-content: center; 
        padding: 16px 0; 
        border-bottom: none;
    }
    .sidebar-brand .logo-img {
        height: 34px;
        max-width: 68px;
        object-fit: contain;
        object-position: center;
    }
    .sidebar-nav a { 
        justify-content: center; 
        padding: 12px; 
    }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .topbar { padding: 0 16px; }
    .topbar-search { max-width: 180px; }
    .page-content { padding: 16px; }
    .slide-over { max-width: 100%; }
    .profile-grid { grid-template-columns: 1fr; }
    .wizard-step .form-row { grid-template-columns: 1fr; }
    .wizard-modal { max-width: 100%; margin: 16px; max-height: 95vh; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .topbar-search { display: none; }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .table-toolbar .search-wrapper { max-width: 100%; }
    .table-toolbar .filter-group { flex-wrap: wrap; }
    .org-table { font-size: 13px; }
    .org-table th, .org-table td { padding: 10px 12px; }
}

/* ===== OVERLAY ===== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.open {
    opacity: 1;
    pointer-events: all;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 380px;
    width: 100%;
}

.toast {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideIn 0.3s ease;
    transition: var(--transition);
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

.toast .toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast .toast-content {
    flex: 1;
}

.toast .toast-content .toast-title {
    font-weight: 600;
    font-size: 14px;
}

.toast .toast-content .toast-message {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.toast .toast-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    padding: 4px;
    transition: var(--transition);
}

.toast .toast-close:hover {
    color: var(--text-primary);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.removing {
    transform: translateX(100%);
    opacity: 0;
}

.hidden { display: none !important; }

/* ===== AUTH SCREENS ===== */
.auth-screen {
            position: fixed;
            inset: 0;
            z-index: 500;
            display: none;
            align-items: center;
            justify-content: center;
            background: var(--bg-body);
            padding: 24px;
        }
.auth-screen.open { display: flex; }
.auth-card {
            width: 100%;
            max-width: 420px;
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-xl);
            padding: 32px;
        }
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 20px;
    gap: 8px;
}
.auth-logo-img {
    height: 52px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}
.auth-brand-tagline {
    margin: 10px 0 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.auth-card .auth-title { font-size: 20px; margin-bottom: 8px; text-align: center; }
.auth-card h1 { font-size: 24px; margin-bottom: 8px; }
.auth-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; text-align: center; }
.auth-login-form { text-align: left; }
.auth-login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 8px;
}
.auth-login-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 48px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    background: var(--input-bg);
    color: var(--text-primary);
}
.auth-login-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.auth-login-input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}
.auth-login-submit {
    width: 100%;
    min-height: 48px;
    margin-top: 4px;
}
.auth-login-submit.is-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: progress;
    opacity: 0.9;
}
.auth-login-submit.is-loading:disabled {
    opacity: 0.9;
}
.auth-spinner {
    display: inline-block;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}
#loginStatus.auth-status-busy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
#loginStatus.auth-status-busy .auth-spinner {
    width: 14px;
    height: 14px;
    color: var(--primary);
}
#loginStatus.auth-status-error {
    color: var(--danger, #dc2626);
}
@keyframes auth-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .auth-spinner { animation-duration: 1.6s; }
}
.company-scope {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-right: 12px;
        }
.company-scope select {
            padding: 8px 12px;
            border-radius: var(--input-radius);
            border: 1px solid var(--border-color);
            background: var(--bg-card);
            color: var(--text-primary);
            font-size: 13px;
            min-width: min(420px, 42vw);
            max-width: 520px;
        }

/* ===== SIDEBAR FOOTER ===== */
.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px 12px;
}
.sidebar-user .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.sidebar-user-info .name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-info .email {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-info .role-tag {
    display: block;
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    text-transform: capitalize;
}
.sidebar-logout {
    width: 100%;
    justify-content: center;
}

/* ===== DASHBOARD ===== */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}
.dashboard-header-left h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}
.dashboard-header-left .welcome-text {
    color: var(--text-secondary);
    font-size: 14px;
}
.demo-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--warning);
    background: var(--warning-light);
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 6px;
    vertical-align: middle;
}
.dashboard-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.date-range-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}
.date-range-picker input[type="date"] {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
}
.kpi-grid-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}
@media (max-width: 1200px) {
    .kpi-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .kpi-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.kpi-card .icon-wrapper.purple { background: rgba(139, 92, 246, 0.12); color: var(--primary-light); }
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}
.chart-card-line {
    min-height: 320px;
}
.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.chart-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.chart-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.legend-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.legend-item .dot.purple { background: #8B5CF6; }
.legend-item .dot.green { background: #10B981; }
.legend-item .dot.blue { background: #3B82F6; }
.legend-item .dot.orange { background: #F59E0B; }
.chart-canvas-wrap {
    height: 240px;
    position: relative;
}
.dashboard-triple {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}
.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: 16px;
}
.panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    flex: 1 1 180px;
    min-width: 0;
}
.panel-header--split .panel-header-tabs {
    flex: 1 1 100%;
    margin: 0;
    justify-content: flex-start;
}
@media (min-width: 960px) {
    .panel-header--split .panel-header-tabs {
        flex: 1 1 auto;
        max-width: min(100%, 640px);
        justify-content: flex-end;
    }
}
.panel-header .segmented-control .segment {
    white-space: nowrap;
}
.panel-link {
    font-size: 13px;
    color: var(--primary-light);
    font-weight: 500;
}
.panel-link:hover { text-decoration: underline; }
.empty-panel {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
}
.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.conversation-item {
    display: flex;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.conversation-item:hover { background: var(--bg-hover); }
.conv-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-glow);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}
.conv-body { flex: 1; min-width: 0; }
.conv-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}
.conv-name { font-weight: 600; font-size: 14px; }
.conv-time { font-size: 11px; color: var(--text-muted); }
.conv-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}
.conv-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.conv-company {
    font-size: 11px;
    color: var(--text-muted);
}
.conv-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.conv-badge.new { background: var(--info-light); color: var(--info); }
.conv-badge.in_progress, .conv-badge.open { background: var(--warning-light); color: var(--warning); }
.conv-badge.human_takeover { background: var(--danger-light); color: var(--danger); }
.conv-badge.closed { background: var(--success-light); color: var(--success); }
.agent-rank-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.agent-rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.agent-rank-item:hover { background: var(--bg-hover); }
.rank-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-glow);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-weight: 600; font-size: 14px; }
.rank-meta { font-size: 12px; color: var(--text-muted); }
.rank-pct {
    text-align: right;
    font-weight: 700;
    font-size: 16px;
    color: var(--success);
}
.rank-pct span {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
}
.system-status-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-body);
    border: 1px solid var(--border-color);
}
.status-row.ok .status-right { color: var(--success); }
.status-row.warn .status-right { color: var(--warning); }
.status-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
}
.status-left i { color: var(--text-muted); width: 18px; text-align: center; }
.status-right {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}
.dashboard-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 0;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-muted);
}
.dashboard-footer .version {
    font-family: monospace;
    font-size: 12px;
}

/* ===== MISSION CONTROL / OPERATIONS CENTER ===== */
.ops-subtitle {
    font-size: 13px;
    max-width: 560px;
}
.mc-platform-partial-note {
    max-width: none;
    margin: 0 0 12px;
    font-size: 12px;
    line-height: 1.35;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
@media (max-width: 900px) {
    .mc-platform-partial-note {
        white-space: normal;
    }
}
/* ===== PLATFORM INTELLIGENCE DASHBOARD (PI-4E) ===== */
.pi-global-period {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--card-bg, rgba(15, 23, 42, 0.04));
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.25));
}
.pi-period-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.pi-period-btn {
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.35));
    background: transparent;
    color: inherit;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
}
.pi-period-btn.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: #8b5cf6;
    color: #8b5cf6;
    font-weight: 600;
}
.pi-period-label {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}
.pi-period-custom {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.pi-channel-coverage {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}
.pi-channel-chip {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 600;
}
.pi-channel-live {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}
.pi-channel-pending {
    background: rgba(148, 163, 184, 0.2);
    color: #64748b;
}
.pi-channel-note {
    font-size: 11px;
    opacity: 0.75;
    flex: 1 1 100%;
}
.pi-network-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
@media (max-width: 960px) {
    .pi-network-grid {
        grid-template-columns: 1fr;
    }
}
.pi-network-panel {
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.25));
    border-radius: 12px;
    padding: 16px;
    background: var(--card-bg, #fff);
}
.pi-panel-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.pi-panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
}
.pi-panel-scope {
    font-size: 12px;
    opacity: 0.8;
}
.pi-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.pi-kpi-card {
    padding: 10px;
    border-radius: 8px;
    background: rgba(139, 92, 246, 0.06);
    text-align: center;
}
.pi-kpi-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
}
.pi-kpi-label {
    font-size: 11px;
    opacity: 0.85;
}
.pi-table-wrap {
    overflow-x: auto;
}
.pi-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.pi-data-table th,
.pi-data-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.pi-row-pending td {
    opacity: 0.75;
    font-style: italic;
}
.pi-comms-snapshots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}
@media (max-width: 720px) {
    .pi-comms-snapshots {
        grid-template-columns: 1fr;
    }
}
.pi-comms-snap {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.2);
}
.pi-comms-snap-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    opacity: 0.75;
}
.pi-comms-snap-value {
    font-size: 1.35rem;
    font-weight: 700;
}
.pi-comms-snap-sub {
    font-size: 11px;
    opacity: 0.8;
}
.pi-rank-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    align-items: center;
}
.pi-rank-btn {
    border: none;
    background: rgba(148, 163, 184, 0.15);
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
}
.pi-rank-btn.active {
    background: rgba(139, 92, 246, 0.2);
    color: #7c3aed;
    font-weight: 600;
}
.pi-sector-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.pi-sector-list li {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
.pi-sector-rank {
    font-weight: 700;
    min-width: 1.5rem;
    color: #8b5cf6;
}
.pi-sector-name {
    font-weight: 600;
    min-width: 120px;
}
.pi-sector-metrics {
    font-size: 12px;
    opacity: 0.85;
}
.pi-assessment-panel {
    margin: 16px 0;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(34, 197, 94, 0.04);
}
.pi-assessment-list {
    margin: 8px 0 0;
    padding-left: 0;
    list-style: none;
}
.pi-assessment-list li {
    padding: 4px 0;
    font-size: 13px;
}
.pi-panel-hint {
    font-size: 11px;
    opacity: 0.75;
    margin: 8px 0 0;
}
.pi-error-banner {
    padding: 10px 14px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    font-size: 13px;
}
.pi-ops-section-title {
    margin: 24px 0 12px;
    font-size: 1rem;
}

.kpi-grid-ops {
    grid-template-columns: repeat(5, 1fr);
}
.kpi-card .icon-wrapper.orange { background: rgba(249, 115, 22, 0.12); color: #F97316; }
.ops-grid {
    display: grid;
    gap: 24px;
    margin-bottom: 28px;
}
.ops-row-1 {
    grid-template-columns: 1.4fr 1fr;
}
.ops-row-2 {
    grid-template-columns: repeat(3, 1fr);
}
.ops-row-3 {
    grid-template-columns: 1.6fr 1fr;
}
.ops-activity-scroll {
    max-height: 340px;
    overflow-y: auto;
    padding-right: 4px;
}
.ops-activity-scroll::-webkit-scrollbar { width: 6px; }
.ops-activity-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
.ops-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--primary-glow);
    color: var(--primary);
}
.takeover-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.takeover-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-body);
}
.takeover-item:hover { background: var(--bg-hover); }
.takeover-customer { font-weight: 600; font-size: 14px; }
.takeover-meta { font-size: 12px; color: var(--text-muted); margin: 2px 0; }
.takeover-reason {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}
.takeover-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.trending-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.trending-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.trending-item:hover { background: var(--bg-hover); }
.trending-rank {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary-glow);
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.trending-q { font-size: 13px; font-weight: 500; line-height: 1.4; }
.trending-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.rank-stats {
    display: flex;
    gap: 12px;
    text-align: right;
}
.rank-stat {
    font-weight: 700;
    font-size: 14px;
    color: var(--success);
}
.rank-stat small {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
}
.company-rank-list { display: flex; flex-direction: column; gap: 8px; }
.ops-heatmap { min-height: 300px; }
.ops-chart-wrap { height: 220px; }

@media (max-width: 1400px) {
    .kpi-grid-ops { grid-template-columns: repeat(3, 1fr); }
    .ops-row-2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1200px) {
    .ops-row-1,
    .ops-row-3 { grid-template-columns: 1fr; }
    .ops-row-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .kpi-grid-ops { grid-template-columns: repeat(2, 1fr); }
}

/* ===== INBOX / LIVE CONVERSATIONS ===== */
.inbox-page { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.inbox-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.inbox-search { flex: 1; min-width: 200px; max-width: 320px; margin: 0 !important; }
.inbox-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.inbox-filter-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 999px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.inbox-filter-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.inbox-filter-btn.active {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}
.inbox-source-badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--primary-glow);
    color: var(--primary);
    font-weight: 600;
}
.inbox-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 0;
    height: calc(100vh - 220px);
    min-height: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.inbox-layout-3col {
    grid-template-columns: 300px minmax(0, 1fr) 320px;
}
.inbox-list-col {
    border-right: 1px solid var(--border-color);
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.inbox-list {
    overflow-y: auto;
    padding: 8px;
    flex: 1;
    min-height: 0;
}
.inbox-item {
    display: flex;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: var(--transition);
}
.inbox-item:hover { background: var(--bg-hover); }
.inbox-item.active {
    background: var(--primary-glow);
    border-left: 3px solid var(--primary);
}
.inbox-item.unread .name { font-weight: 700; }
.inbox-unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin-left: 6px;
    vertical-align: middle;
}
.inbox-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}
.inbox-item-body { flex: 1; min-width: 0; }
.inbox-item-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}
.inbox-item-top .name { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.inbox-item-top .time { font-size: 11px; color: var(--text-muted); }
.inbox-item-presence { margin-bottom: 4px; }
.presence {
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.presence.online { color: #22c55e; }
.presence.online .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
}
.presence.offline { color: var(--text-muted); }
.inbox-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}
.inbox-item-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.inbox-thread {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border-color);
}
.inbox-thread-empty {
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.thread-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.thread-header-info { flex: 1; min-width: 0; }
.thread-header-actions { flex-shrink: 0; }
.thread-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
}
.thread-name { font-weight: 600; font-size: 16px; }
.thread-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mode-pill {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
}
.mode-pill.ai { background: var(--primary-glow); color: var(--primary); }
.mode-pill.human { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
.thread-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-body);
}
.thread-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
}
.thread-bubble.customer {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}
.thread-bubble.ai {
    align-self: flex-end;
    background: var(--primary-glow);
    border: 1px solid rgba(139, 92, 246, 0.2);
}
.thread-bubble.human {
    align-self: flex-end;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.25);
}
.bubble-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.bubble-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}
.thread-compose {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.thread-compose input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    font-family: inherit;
    font-size: 14px;
    background: var(--bg-body);
    color: var(--text-primary);
    outline: none;
}
.thread-compose input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Right panel — profile + AI */
.inbox-panel {
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-card);
    min-height: 0;
}
.inbox-panel-empty {
    display: flex;
    align-items: center;
    justify-content: center;
}
.panel-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.panel-section:last-child { border-bottom: none; margin-bottom: 0; }
.panel-section h3 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-section h3 i { color: var(--primary); }
.profile-dl {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px 12px;
    margin: 0;
    font-size: 13px;
}
.profile-dl dt { color: var(--text-muted); margin: 0; }
.profile-dl dd { margin: 0; color: var(--text-primary); }
.lead-score {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary-glow);
    color: var(--primary);
    font-weight: 700;
}
.ai-panel .ai-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}
.ai-panel .ai-stat-row strong { color: var(--text-primary); }
.suggested-reply-box {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin: 12px 0;
}
.suggested-reply-box label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}
.suggested-reply-box p {
    font-size: 13px;
    margin: 8px 0 12px;
    color: var(--text-primary);
    line-height: 1.45;
}
.btn-block { width: 100%; margin-bottom: 8px; }
.btn-block:last-child { margin-bottom: 0; }
.mode-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0;
    font-size: 13px;
}
.segmented-control {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.segmented-control .segment {
    padding: 6px 14px;
    border: none;
    background: var(--bg-body);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    color: var(--text-secondary);
}
.segmented-control .segment.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}
.tenant-class-filter {
    margin: 0 0 16px;
    flex-wrap: wrap;
}
.tenant-summary-grid {
    display: grid;
    grid-template-columns: minmax(120px, 1.2fr) repeat(6, 1fr);
    gap: 8px;
    margin: 0 0 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    align-items: center;
}
.tenant-summary-total-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
}
.tenant-summary-total-label,
.tenant-summary-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tenant-summary-cell {
    text-align: center;
}
.tenant-summary-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}
.tenant-class-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 6px;
    vertical-align: middle;
    text-transform: uppercase;
}
.tenant-class-badge.production { background: #1e3a5f; color: #fff; }
.tenant-class-badge.client-zero,
.tenant-class-badge.company-zero { background: #0369a1; color: #fff; }
.tenant-class-badge.pilot { background: #5b21b6; color: #fff; }
.tenant-class-badge.acceptance { background: #0f766e; color: #fff; }
.tenant-class-badge.demo { background: #b45309; color: #fff; }
.tenant-class-badge.test { background: #374151; color: #e5e7eb; }
.tenant-class-badge.unknown { background: #9ca3af; color: #111; }
.panel-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: -8px 0 8px;
}
.panel-section textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    background: var(--bg-body);
    color: var(--text-primary);
    resize: vertical;
}
.tag-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}
.tag-chip.active, .tag-chip-row .tag-chip.active {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.attachment-placeholder {
    padding: 12px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-body);
}
.attachment-placeholder i {
    display: block;
    font-size: 18px;
    margin-bottom: 4px;
    color: var(--primary);
}
#mobileShowProfileBtn { display: none; }

@media (max-width: 1400px) {
    .inbox-layout-3col { grid-template-columns: 280px minmax(0, 1fr) 280px; }
}

@media (max-width: 1400px) {
    .kpi-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1200px) {
    .dashboard-triple { grid-template-columns: 1fr; }
    .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
    .kpi-grid-6 { grid-template-columns: repeat(2, 1fr); }
    .inbox-layout-3col {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 520px;
    }
    .inbox-list-col { max-height: 260px; border-right: none; border-bottom: 1px solid var(--border-color); }
    .inbox-thread { border-right: none; min-height: 420px; }
    .inbox-panel { display: none; }
    .inbox-panel.mobile-visible {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        width: min(360px, 92vw);
        height: 100vh;
        z-index: 200;
        box-shadow: var(--shadow);
    }
    #mobileShowProfileBtn { display: inline-flex; }
    .inbox-layout { grid-template-columns: 1fr; height: auto; }
    .inbox-list { max-height: 280px; border-right: none; border-bottom: 1px solid var(--border-color); }
}

.page-content {
    min-height: 0;
}

/* ===== COMPANIES MODULE ===== */
.demo-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
    background: var(--warning-light);
    border: 1px solid var(--warning);
    border-radius: var(--radius-sm);
    color: var(--warning);
    font-size: 13px;
    font-weight: 500;
}

.companies-toolbar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.view-toggle {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-toggle-btn {
    padding: 8px 12px;
    border: none;
    background: var(--bg-body);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.view-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.view-toggle-btn.active {
    background: var(--primary);
    color: white;
}

.companies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.company-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.company-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.company-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 20px 20px 12px;
}

.company-card-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.company-card-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.company-card-logo .logo-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.company-card-title {
    flex: 1;
    min-width: 0;
}

.company-card-title h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.company-card-industry {
    font-size: 13px;
    color: var(--text-muted);
}

.company-card-badges {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
}

.company-card-body {
    padding: 0 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.company-card-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.company-card-row i {
    width: 16px;
    color: var(--primary);
    text-align: center;
    flex-shrink: 0;
}

.company-card-row span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.company-card-footer {
    margin-top: auto;
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: var(--bg-muted);
}

.company-card-usage {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.company-card-usage i {
    margin-right: 4px;
    color: var(--primary);
}

.company-card-actions {
    display: flex;
    gap: 6px;
}

.company-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.company-stat {
    text-align: center;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.company-stat .stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.company-stat .stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.api-key-mask {
    font-family: monospace;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.slide-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    background: var(--bg-muted);
}

.module-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.module-link {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-body);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-family: inherit;
    color: var(--text-primary);
}

.module-link:hover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.module-link i {
    font-size: 20px;
    color: var(--primary);
    margin-bottom: 4px;
}

.module-link span {
    font-weight: 600;
    font-size: 14px;
}

.module-link small {
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .companies-grid { grid-template-columns: 1fr; }
    .module-links { grid-template-columns: 1fr; }
    .wizard-body .form-row { grid-template-columns: 1fr; }
    .company-card-footer { flex-direction: column; align-items: stretch; }
    .company-card-actions { justify-content: flex-end; }
}

/* Companies table — action menu & form slide-over */
.companies-table-wrap {
    overflow-x: auto;
}

.companies-table .col-actions {
    width: 56px;
    text-align: right;
}

.companies-table tbody tr {
    cursor: default;
}

.company-table-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    padding: 0;
}

.table-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.table-logo-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 13px;
}

.company-name-text {
    font-weight: 500;
    color: var(--text-primary);
}

.text-muted {
    color: var(--text-muted);
    font-size: 13px;
}

.wa-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
}

.wa-connected { color: var(--success); font-size: 12px; }
.wa-disconnected { color: var(--text-muted); font-size: 12px; }

.wa-cell.wa-active { color: var(--success); }
.wa-cell.wa-active-warn { color: var(--warning, #d97706); }
.wa-cell.wa-pending { color: var(--warning, #d97706); }
.wa-cell.wa-ready { color: var(--info, #2563eb); }
.integration-card-status.wa-ready .integration-status-label { color: var(--info, #2563eb); }
.wa-cell.wa-none { color: var(--text-muted); }
.wa-phone-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 4px;
}

.whatsapp-integration-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    background: var(--surface-secondary, var(--bg-secondary));
}

.integration-card-loading {
    color: var(--text-muted);
    font-size: 14px;
}

.integration-card-status {
    font-weight: 600;
    margin-bottom: 8px;
}

.integration-runtime.ready {
    color: var(--success);
    font-size: 13px;
    margin-bottom: 8px;
}

.integration-runtime.warn {
    color: var(--warning, #d97706);
    font-size: 13px;
    margin-bottom: 8px;
}

.integration-missing {
    margin: 8px 0 12px 18px;
    font-size: 13px;
    color: var(--text-secondary);
}

.integration-details {
    display: grid;
    gap: 8px;
    margin: 12px 0;
    font-size: 13px;
}

.integration-details dt {
    color: var(--text-muted);
    font-weight: 500;
}

.integration-details dd {
    margin: 0;
    color: var(--text-primary);
}

.integration-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.integration-activate-summary {
    margin-top: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.integration-activate-summary.ready {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.integration-activate-summary.warn {
    background: rgba(217, 119, 6, 0.1);
    border: 1px solid rgba(217, 119, 6, 0.3);
}

.action-menu {
    position: relative;
    display: inline-block;
}

.action-menu-trigger {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 6px 10px;
}

.action-menu-trigger:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.action-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    overflow: hidden;
}

.action-menu.open .action-menu-dropdown {
    display: block;
    animation: fadeIn 0.15s ease;
}

.action-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
}

.action-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.action-menu-item.danger {
    color: var(--danger);
}

.action-menu-item.danger:hover {
    background: var(--danger-light);
}

.action-menu-item i {
    width: 16px;
    text-align: center;
    font-size: 13px;
}

.slide-over-form {
    max-width: 640px;
    z-index: 110;
}

.slide-over-form .company-form-body .form-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.slide-over-form .company-form-body .form-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.slide-over-form .company-form-body .form-section h4 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.slide-over-form .company-form-body .form-group {
    margin-bottom: 16px;
}

.slide-over-form .company-form-body .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.slide-over-form .company-form-body .form-group .label-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 12px;
}

.slide-over-form .company-form-body .form-group input,
.slide-over-form .company-form-body .form-group select,
.slide-over-form .company-form-body .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.slide-over-form .company-form-body .form-group input:focus,
.slide-over-form .company-form-body .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.slide-over-form .company-form-body .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.slide-over-form .company-form-body .input-with-action {
    display: flex;
    gap: 8px;
}

.slide-over-form .company-form-body .input-with-action input {
    flex: 1;
}

.form-check .checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}

.form-check .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

@media (max-width: 768px) {
    .slide-over-form .company-form-body .form-row {
        grid-template-columns: 1fr;
    }
    .companies-table .col-actions,
    .companies-table th:nth-child(2),
    .companies-table td:nth-child(2) {
        /* keep essential columns on mobile */
    }
}

@media (max-width: 640px) {
    .companies-table th:nth-child(6),
    .companies-table td:nth-child(6) {
        display: none;
    }
}

/* ===== KNOWLEDGE BASE — AI TRAINING CENTER ===== */
.kb-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.kb-kpi-grid {
    grid-template-columns: repeat(5, 1fr);
}

.kb-kpi-date {
    font-size: 18px !important;
}

.kb-layout {
    display: grid;
    grid-template-columns: 220px 1fr 280px;
    gap: 24px;
    align-items: start;
}

.kb-sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 24px;
}

.kb-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
}

.kb-nav-item i {
    width: 18px;
    text-align: center;
    color: var(--text-muted);
}

.kb-nav-item:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

.kb-nav-item.active {
    background: var(--primary-glow);
    color: var(--primary);
    font-weight: 600;
}

.kb-nav-item.active i {
    color: var(--primary);
}

.kb-main {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    min-height: 480px;
}

.kb-section-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.kb-section-toolbar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 16px;
}

.kb-section-toolbar-dual,
.kb-empty-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.kb-section-toolbar-dual {
    justify-content: flex-start;
}

.kb-narrative-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--primary);
    margin-bottom: 8px;
}

.kb-narrative-preview {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.kb-entry-heading h4 {
    margin: 6px 0 0;
}

.kb-service-header {
    align-items: flex-start;
}

.kb-entry-card .kb-price-content {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 14px;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    max-height: 240px;
    overflow: auto;
}

.kb-section-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.kb-section-header h2 i {
    color: var(--primary);
}

.kb-training-queue {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 24px;
}

.kb-queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.kb-queue-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kb-queue-header h3 i {
    color: var(--warning);
}

.kb-queue-count {
    font-size: 12px;
    background: var(--primary-glow);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.kb-queue-idle {
    text-align: center;
    padding: 24px 12px;
    color: var(--text-muted);
}

.kb-queue-idle i {
    font-size: 28px;
    color: var(--success);
    margin-bottom: 8px;
}

.kb-queue-idle p {
    font-size: 13px;
    margin: 0;
}

.kb-queue-job {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 12px;
}

.kb-queue-job:last-child {
    margin-bottom: 0;
}

.kb-queue-job-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kb-queue-steps {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kb-queue-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.kb-queue-step.done {
    color: var(--success);
}

.kb-queue-step.active {
    color: var(--primary);
    font-weight: 600;
}

.kb-step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    flex-shrink: 0;
}

.kb-queue-step.done .kb-step-dot {
    background: var(--success);
}

.kb-queue-step.active .kb-step-dot {
    background: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    animation: kb-pulse 1.2s ease infinite;
}

@keyframes kb-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--primary-glow); }
    50% { box-shadow: 0 0 0 6px transparent; }
}

.kb-file-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.kb-file-icon {
    font-size: 24px;
    color: var(--danger);
}

.kb-file-name {
    font-weight: 500;
}

.kb-file-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.kb-faq-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.kb-faq-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
}

.kb-faq-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.kb-faq-q {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kb-faq-q i {
    color: var(--primary);
}

.kb-faq-a {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 10px;
}

.kb-faq-footer {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.kb-faq-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.kb-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.kb-product-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.kb-product-image {
    height: 140px;
    background: linear-gradient(135deg, var(--primary-glow), var(--bg-body));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--primary);
}

.kb-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kb-product-body {
    padding: 16px;
    flex: 1;
}

.kb-product-body h4 {
    margin: 0 0 6px;
    font-size: 16px;
}

.kb-product-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.kb-product-spec {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 8px;
    line-height: 1.5;
}

.kb-product-features,
.kb-product-warranty {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.kb-product-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

.kb-service-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.kb-service-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.kb-service-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.kb-service-header h4 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kb-service-header h4 i {
    color: var(--primary);
}

.kb-service-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    margin: 10px 0;
    color: var(--text-secondary);
}

.kb-service-req {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

.kb-service-actions {
    display: flex;
    gap: 4px;
}

.kb-policy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.kb-policy-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.kb-policy-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--primary-glow);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}

.kb-policy-card h4 {
    margin: 0 0 8px;
    font-size: 15px;
}

.kb-policy-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
    margin: 0 0 12px;
}

.kb-policy-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.kb-price-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 16px;
}

.kb-price-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.kb-price-header h4 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kb-price-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.8;
    white-space: pre-wrap;
    margin: 0;
}

.kb-price-footer {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
}

.kb-website-import .kb-import-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.kb-import-input-wrap {
    flex: 1;
    min-width: 240px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 14px;
}

.kb-import-input-wrap i {
    color: var(--text-muted);
}

.kb-import-input-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 0;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    color: var(--text-primary);
}

.kb-modal { max-width: 560px; }
.kb-modal-wide { max-width: 720px; }

.kb-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-body);
}

.kb-upload-zone:hover,
.kb-upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.kb-upload-zone i {
    font-size: 36px;
    color: var(--primary);
    margin-bottom: 12px;
}

.kb-upload-zone p {
    font-weight: 500;
    margin: 0 0 4px;
}

.kb-upload-zone small {
    color: var(--text-muted);
    font-size: 12px;
}

.kb-upload-filename {
    margin-top: 12px;
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
}

.kb-rich-editor {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.kb-editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg-body);
    border-bottom: 1px solid var(--border-color);
}

.kb-toolbar-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.kb-toolbar-btn:hover {
    background: var(--bg-card);
    color: var(--primary);
}

.kb-editor-area {
    min-height: 200px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.7;
    outline: none;
    color: var(--text-primary);
}

.kb-editor-area:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
}

.wizard-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin: 4px 0 0;
    font-weight: 400;
}

@media (max-width: 1200px) {
    .kb-layout {
        grid-template-columns: 200px 1fr;
    }
    .kb-training-queue {
        grid-column: 1 / -1;
        position: static;
    }
    .kb-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .kb-layout {
        grid-template-columns: 1fr;
    }
    .kb-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        position: static;
    }
    .kb-nav-item {
        width: auto;
        flex: 1 1 auto;
        min-width: 120px;
        justify-content: center;
    }
    .kb-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .kb-header-actions {
        width: 100%;
        justify-content: stretch;
    }
    .kb-header-actions .btn {
        flex: 1 1 auto;
    }
}

@media (max-width: 480px) {
    .kb-kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== CUSTOMER CRM ===== */
.crm-source-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--primary-glow);
    color: var(--primary);
}

.crm-toolbar {
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.crm-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.crm-filter-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.crm-filter-btn.active,
.crm-filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-glow);
}

.crm-name-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.crm-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-glow);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.crm-detail-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.crm-detail-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crm-header-card {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
    padding: 24px;
}

.crm-header-main {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.crm-header-avatar {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.crm-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.crm-header-title h2 {
    font-size: 24px;
}

.crm-header-contact,
.crm-header-meta {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.crm-header-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.crm-header-stats div {
    background: var(--bg-muted);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.crm-header-stats span {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.crm-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.crm-tab {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
}

.crm-tab.active {
    background: var(--primary-glow);
    color: var(--primary);
    font-weight: 600;
}

.crm-tab-panel {
    min-height: 320px;
}

.crm-overview-grid,
.crm-analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.crm-rec-card {
    border-left: 4px solid var(--primary);
}

.crm-rec-action {
    margin: 8px 0;
    line-height: 1.5;
}

.crm-rec-confidence {
    margin-top: 12px;
    color: var(--primary);
    font-size: 13px;
}

.crm-score-card h3,
.crm-rec-card h3 {
    margin-bottom: 12px;
    font-size: 15px;
}

.crm-score-total {
    margin-bottom: 12px;
    font-size: 14px;
}

.crm-score-row {
    display: grid;
    grid-template-columns: 1fr 1.2fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
}

.crm-score-bar {
    height: 8px;
    background: var(--border-light);
    border-radius: 999px;
    overflow: hidden;
}

.crm-score-bar div {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.crm-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.crm-timeline-item {
    display: flex;
    gap: 12px;
}

.crm-timeline-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-glow);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.crm-timeline-title {
    font-weight: 600;
    font-size: 14px;
}

.crm-timeline-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

.crm-timeline-time {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

.crm-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 520px;
    overflow-y: auto;
    padding: 8px 0;
}

.crm-summary-text {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    margin: 12px 0;
    background: var(--bg-muted);
    color: var(--text-primary);
}

.crm-note-item,
.crm-task-item {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-muted);
}

.crm-note-meta,
.crm-task-meta {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.crm-add-form {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crm-task-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.crm-task-form button {
    grid-column: 1 / -1;
}

.crm-task-item.done {
    opacity: 0.65;
    text-decoration: line-through;
}

.crm-task-meta .priority.high { color: var(--danger); }
.crm-task-meta .priority.medium { color: var(--warning); }
.crm-task-meta .priority.low { color: var(--success); }

.crm-doc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crm-doc-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
}

.crm-doc-item span {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
}

.crm-tab-actions {
    margin-bottom: 12px;
}

@media (max-width: 900px) {
    .crm-header-card,
    .crm-overview-grid,
    .crm-analytics-grid {
        grid-template-columns: 1fr;
    }
}


/* ===== AI EMPLOYEES MODULE ===== */
.employees-table-wrap {
    overflow-x: auto;
}

.employees-table .col-actions {
    width: 56px;
    text-align: right;
}

.employees-table tbody tr {
    cursor: default;
}

.employee-table-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-glow);
    flex-shrink: 0;
}

.employee-avatar-emoji {
    font-size: 22px;
    line-height: 1;
}

.employee-avatar-initials {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
}

.employee-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.model-tag {
    font-family: monospace;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.status-badge i {
    margin-right: 4px;
}

.employee-wizard-body .form-group {
    margin-bottom: 16px;
}

.employee-wizard-body .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.employee-wizard-body .form-group input,
.employee-wizard-body .form-group select,
.employee-wizard-body .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.employee-wizard-body .form-group input:focus,
.employee-wizard-body .form-group select:focus,
.employee-wizard-body .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.employee-wizard-body .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.employee-wizard-slide {
    max-width: 720px;
    z-index: 110;
}

.employee-wizard-body {
    padding: 24px 28px;
}

.employee-wizard-body .wizard-step {
    display: none;
}

.employee-wizard-body .wizard-step.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.employee-wizard-body .wizard-step h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.employee-wizard-body .wizard-step .step-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.wizard-progress-bar {
    height: 4px;
    background: var(--border-color);
    flex-shrink: 0;
}

.wizard-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 0.3s ease;
}

.employee-wizard-footer {
    justify-content: space-between;
}

.employee-wizard-footer .btn-group {
    display: flex;
    gap: 10px;
}

.role-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.role-card {
    cursor: pointer;
}

.role-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.role-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-align: center;
    background: var(--bg-body);
}

.role-card:hover .role-card-inner {
    border-color: var(--primary-light);
    background: var(--bg-hover);
}

.role-card input:checked + .role-card-inner {
    border-color: var(--primary);
    background: var(--primary-glow);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.role-icon {
    font-size: 24px;
}

.role-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.personality-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.personality-card {
    cursor: pointer;
}

.personality-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.personality-card-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    background: var(--bg-body);
    height: 100%;
}

.personality-card:hover .personality-card-inner {
    border-color: var(--primary-light);
}

.personality-card input:checked + .personality-card-inner {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.personality-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.personality-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.avatar-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.avatar-preset {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-body);
    font-size: 22px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-preset:hover {
    border-color: var(--primary-light);
    transform: scale(1.05);
}

.avatar-preset.selected {
    border-color: var(--primary);
    background: var(--primary-glow);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.knowledge-check .checkbox-label,
.channel-check .checkbox-label {
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-body);
    transition: var(--transition);
    width: 100%;
}

.knowledge-check .checkbox-label:hover,
.channel-check .checkbox-label:hover {
    border-color: var(--primary-light);
    background: var(--bg-hover);
}

.knowledge-check input:checked + i,
.channel-check input:checked ~ i,
.knowledge-check .checkbox-label:has(input:checked),
.channel-check .checkbox-label:has(input:checked) {
    color: var(--primary);
}

.knowledge-check .checkbox-label:has(input:checked),
.channel-check .checkbox-label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.knowledge-check i,
.channel-check i {
    width: 18px;
    text-align: center;
    color: var(--text-muted);
}

.upload-placeholder {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-body);
}

.upload-placeholder i {
    font-size: 32px;
    color: var(--primary-light);
    margin-bottom: 12px;
}

.upload-placeholder p {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.upload-placeholder small {
    font-size: 12px;
}

.range-slider {
    width: 100%;
    accent-color: var(--primary);
    margin-top: 8px;
}

.memory-toggle {
    display: flex;
    align-items: flex-end;
    padding-bottom: 4px;
}

.preview-chat {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
    min-height: 360px;
}

.preview-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
}

.preview-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.preview-name {
    font-weight: 600;
    font-size: 16px;
}

.preview-role {
    font-size: 13px;
    color: var(--text-muted);
}

.preview-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 220px;
}

.preview-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
}

.preview-bubble.ai {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.preview-bubble.customer {
    align-self: flex-end;
    background: var(--primary-glow);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.preview-bubble .bubble-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.preview-compose {
    display: flex;
    gap: 8px;
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.preview-compose input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--bg-body);
    color: var(--text-primary);
    outline: none;
}

.preview-compose input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

@media (max-width: 768px) {
    .employee-wizard-slide { max-width: 100%; }
    .role-cards { grid-template-columns: repeat(2, 1fr); }
    .personality-cards { grid-template-columns: 1fr 1fr; }
    .employees-table th:nth-child(4),
    .employees-table td:nth-child(4),
    .employees-table th:nth-child(7),
    .employees-table td:nth-child(7) {
        display: none;
    }
}

@media (max-width: 480px) {
    .personality-cards { grid-template-columns: 1fr; }
    .employees-table th:nth-child(2),
    .employees-table td:nth-child(2) {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Workflow Automation Studio
   ═══════════════════════════════════════════════════════════════ */

.automation-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.automation-stats .stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.automation-stats .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.automation-stats .stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

.automation-table-card {
    overflow-x: auto;
}

.automation-table .trigger-chip {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(124, 58, 237, 0.1);
    color: var(--accent);
    margin-right: 4px;
}

.wf-name-link {
    color: var(--accent);
    cursor: pointer;
}

.wf-name-link:hover {
    text-decoration: underline;
}

/* ── Workflow Builder (full-page overlay) ── */

.workflow-builder {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--bg-main);
    flex-direction: column;
}

.workflow-builder.open {
    display: flex;
}

.builder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    gap: 16px;
    flex-wrap: wrap;
}

.builder-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.builder-name-input {
    font-size: 18px;
    font-weight: 700;
    border: none;
    background: transparent;
    color: var(--text-primary);
    padding: 4px 0;
    min-width: 240px;
}

.builder-name-input:focus {
    outline: none;
    border-bottom: 2px solid var(--accent);
}

.builder-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    font-size: 12px;
}

.builder-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.builder-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.builder-canvas-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    background: var(--bg-muted);
}

.builder-canvas {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.builder-side-panel {
    width: 340px;
    border-left: 1px solid var(--border-light);
    background: var(--bg-card);
    overflow-y: auto;
    padding: 24px;
}

.side-panel-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 16px;
}

.side-panel-empty i {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.side-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.side-panel-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.side-panel-type {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.side-panel-label {
    font-size: 16px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-primary);
    width: 100%;
    padding: 2px 0;
}

.side-panel-label:focus {
    outline: none;
}

/* ── Flow nodes & connectors ── */

.flow-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.flow-line {
    width: 2px;
    height: 20px;
    background: var(--border);
}

.flow-add-step {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px dashed var(--accent);
    background: var(--bg-card);
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.15s;
}

.flow-add-step:hover {
    background: var(--accent);
    color: #fff;
    border-style: solid;
}

.flow-node {
    width: 100%;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
    cursor: pointer;
}

.flow-node.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.flow-node-type {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 6px 14px;
    background: color-mix(in srgb, var(--node-color, #7c3aed) 12%, transparent);
    color: var(--node-color, #7c3aed);
}

.flow-node-body {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
}

.flow-node-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--node-color, #7c3aed) 15%, transparent);
    color: var(--node-color, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.flow-node-content {
    flex: 1;
    min-width: 0;
}

.flow-node-content strong {
    display: block;
    font-size: 14px;
}

.flow-node-summary {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-node-delete {
    opacity: 0;
    transition: opacity 0.15s;
}

.flow-node:hover .flow-node-delete {
    opacity: 1;
}

.flow-empty {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

/* ── Branch fork ── */

.flow-branch {
    width: 100%;
    position: relative;
    margin: 8px 0;
}

.flow-branch-line {
    width: 2px;
    height: 24px;
    background: var(--border);
    margin: 0 auto;
}

.flow-branch-paths {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.flow-branch-path {
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    min-height: 60px;
}

.branch-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    margin-bottom: 8px;
}

.branch-label.yes {
    background: rgba(5, 150, 105, 0.12);
    color: #059669;
}

.branch-label.no {
    background: rgba(220, 38, 38, 0.12);
    color: #dc2626;
}

.branch-empty {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Step picker modal ── */

.step-picker-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.step-picker-modal.open {
    display: flex;
}

.step-picker-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.step-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.step-picker-header h3 {
    margin: 0;
    font-size: 18px;
}

.step-picker-categories {
    padding: 16px 24px 24px;
}

.step-category h4 {
    font-size: 13px;
    color: var(--accent);
    margin: 16px 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-category:first-child h4 {
    margin-top: 0;
}

.step-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.step-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
}

.step-option:hover {
    border-color: var(--accent);
    background: rgba(124, 58, 237, 0.04);
}

.step-option i {
    font-size: 18px;
    color: var(--accent);
    margin-top: 2px;
}

.step-option strong {
    display: block;
    font-size: 14px;
}

.step-option span {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Version panel ── */

.version-panel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(0, 0, 0, 0.3);
    justify-content: flex-end;
}

.version-panel.open {
    display: flex;
}

.version-panel-inner {
    width: 380px;
    max-width: 100%;
    background: var(--bg-card);
    height: 100%;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.version-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.version-panel-header h3 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.version-list {
    padding: 16px 24px;
}

.version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
}

.version-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
}

/* ── Integrations drawer ── */

.integrations-drawer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(0, 0, 0, 0.3);
    justify-content: flex-end;
}

.integrations-drawer.open {
    display: flex;
}

.integrations-drawer-inner {
    width: 420px;
    max-width: 100%;
    background: var(--bg-card);
    height: 100%;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.integrations-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.integrations-drawer-header h3 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.automation-integrations {
    padding: 16px 24px 24px;
}

.integrations-section h4 {
    font-size: 13px;
    margin: 16px 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.integrations-section:first-child h4 {
    margin-top: 0;
}

.integration-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.integration-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
}

.integration-card.coming_soon {
    opacity: 0.7;
}

.integration-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(124, 58, 237, 0.1);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.integration-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    font-size: 13px;
}

.integration-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.integration-badge.connected {
    background: rgba(5, 150, 105, 0.12);
    color: #059669;
}

.integration-badge.coming-soon {
    background: rgba(124, 58, 237, 0.1);
    color: var(--accent);
}

/* ── Templates gallery ── */

.templates-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.4);
    align-items: flex-start;
    justify-content: center;
    padding: 40px 24px;
    overflow-y: auto;
}

.templates-overlay.open {
    display: flex;
}

.templates-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 960px;
    box-shadow: var(--shadow-lg);
}

.templates-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-light);
}

.templates-header h2 {
    margin: 0 0 4px;
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.templates-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    gap: 16px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-light);
}

.templates-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tpl-filter {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.tpl-filter.active,
.tpl-filter:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.templates-company-select {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.templates-company-select select {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 24px 28px 28px;
}

.template-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.template-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.08);
}

.template-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: rgba(124, 58, 237, 0.1);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.template-industry {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
}

.template-card h3 {
    margin: 0;
    font-size: 16px;
}

.template-card p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
    flex: 1;
}

.template-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.template-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Create workflow modal ── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.open {
    display: flex;
}

.modal-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.modal-card h3 {
    margin: 0 0 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

@media (max-width: 900px) {
    .automation-stats {
        grid-template-columns: 1fr;
    }

    .builder-body {
        flex-direction: column;
    }

    .builder-side-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-light);
        max-height: 40vh;
    }

    .builder-canvas-wrap {
        padding: 16px;
    }

    .flow-branch-paths {
        grid-template-columns: 1fr;
    }

    .templates-grid {
        grid-template-columns: 1fr;
    }
}

/* Company cross-links in Super Admin companies table */
.company-cross-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.company-cross-links .cross-link,
.company-cross-links .cross-link-btn {
    font-size: 11px;
    color: var(--text-muted, #64748b);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
}

.company-cross-links .cross-link:hover,
.company-cross-links .cross-link-btn:hover {
    color: var(--primary, #1e40af);
    text-decoration: underline;
}

/* ── AI Marketplace ── */
.marketplace-section {
    margin-bottom: 32px;
}

.marketplace-section-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.marketplace-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.marketplace-scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface-2, rgba(99, 102, 241, 0.12));
    color: var(--primary, #1e40af);
    font-size: 13px;
}

.marketplace-scope-badge.warn {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

.marketplace-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.marketplace-category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    background: var(--card-bg, #fff);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.marketplace-category-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-color: var(--cat-color, #6366f1);
}

.marketplace-category-card .cat-icon {
    font-size: 28px;
}

.marketplace-category-card .cat-label {
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.marketplace-category-card .cat-count {
    font-size: 11px;
    color: var(--text-muted, #64748b);
}

.marketplace-pack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.marketplace-pack-card {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 14px;
    padding: 18px;
    background: var(--card-bg, #fff);
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 3px solid var(--pack-color, #6366f1);
}

.pack-card-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.pack-icon {
    font-size: 32px;
    line-height: 1;
}

.pack-card-header h4 {
    margin: 0 0 4px;
    font-size: 15px;
}

.pack-tagline {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted, #64748b);
}

.pack-includes {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 12px;
}

.pack-includes li {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    color: var(--text-muted, #64748b);
}

.pack-includes li i {
    color: var(--success, #16a34a);
    font-size: 10px;
}

.pack-card-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border, #e2e8f0);
}

.pack-card-footer > * {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    justify-content: center;
    text-align: center;
}

.pack-card-footer .mp-contact-sales {
    flex: 1 1 100%;
    order: -1;
    white-space: normal;
    line-height: 1.3;
    font-size: 12px;
    padding: 8px 10px;
}

.pack-meta {
    font-size: 11px;
    color: var(--text-muted, #64748b);
}

.pack-status.installed {
    color: var(--success, #16a34a);
    font-size: 12px;
    font-weight: 600;
}

.pack-status.soon {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2, #f1f5f9);
    color: var(--text-muted, #64748b);
}

.marketplace-installed-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.marketplace-installed-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    background: var(--card-bg, #fff);
}

.marketplace-installed-item > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
    flex: 1 1 220px;
}

.marketplace-installed-item strong {
    display: block;
    line-height: 1.35;
    color: var(--text-primary);
}

.marketplace-installed-item .text-muted {
    margin: 0;
    display: block;
    line-height: 1.45;
    font-size: 12px;
}

.marketplace-pack-card {
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.marketplace-pack-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.marketplace-category-card.active {
    border-color: var(--cat-color, var(--primary));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--cat-color, var(--primary)) 25%, transparent);
}

.installed-actions {
    display: flex;
    gap: 6px;
}

.marketplace-coming-soon-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.08));
    margin-bottom: 16px;
}

.marketplace-coming-soon-banner i {
    font-size: 28px;
    color: var(--primary, #6366f1);
}

.marketplace-tp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.marketplace-tp-card {
    position: relative;
    padding: 16px;
    border: 1px dashed var(--border, #cbd5e1);
    border-radius: 12px;
    opacity: 0.85;
}

.marketplace-tp-card h4 {
    margin: 8px 0 6px;
    font-size: 14px;
}

.tp-badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #64748b);
}

.tp-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted, #64748b);
    margin-top: 8px;
}

/* Marketplace search, filters, modals, wizard */
.marketplace-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.marketplace-search-wrap {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    background: var(--card-bg, #fff);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.marketplace-search-wrap:focus-within {
    border-color: var(--primary, #6366f1);
    box-shadow: 0 0 0 3px var(--primary-glow, rgba(99, 102, 241, 0.2));
}

.marketplace-search-wrap i,
.marketplace-search-wrap .search-icon {
    position: static;
    transform: none;
    flex-shrink: 0;
    color: var(--text-muted, #64748b);
    font-size: 13px;
    pointer-events: none;
    line-height: 1;
}

/* Match global form-control specificity so left padding actually wins. */
.marketplace-search-wrap input.marketplace-search-input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="image"]),
.marketplace-search-input {
    width: 100%;
    min-width: 0;
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    padding: 10px 0;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary, #0f172a);
}

.marketplace-search-wrap input.marketplace-search-input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="image"]):focus {
    outline: none;
    border: none;
    box-shadow: none;
}

.marketplace-filter-select {
    padding: 10px 12px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    font-size: 13px;
    background: var(--card-bg, #fff);
}

.mp-stars {
    color: #f59e0b;
    font-size: 12px;
    letter-spacing: 1px;
}

.mp-rating-count {
    font-size: 11px;
    color: var(--text-muted, #64748b);
}

.mp-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.mp-price {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
}

.mp-price.free {
    background: rgba(22, 163, 74, 0.12);
    color: #16a34a;
}

.mp-price.paid {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
}

.mp-update-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #ea580c;
    margin-left: 8px;
}

.mp-lifecycle-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    color: #2563eb;
}

.mp-lifecycle-stale {
    color: #b45309;
}

.mp-lifecycle-error {
    margin: 8px 0 0;
    font-size: 13px;
    color: #b91c1c;
}

.mp-lifecycle-failed-text {
    color: #b91c1c;
}

.mp-update-changelog {
    margin: 8px 0 0 16px;
    font-size: 13px;
    color: var(--text-muted, #64748b);
}

.mp-pack-update {
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    background: var(--surface-muted, #f8fafc);
}

.mp-pack-update h4 {
    margin: 0 0 8px;
    font-size: 15px;
}

.mp-pack-update-warning {
    font-size: 13px;
    line-height: 1.45;
    margin: 10px 0;
    color: #b45309;
}

.mp-pack-update-permission {
    margin: 10px 0 0;
    font-size: 13px;
}

.mp-pack-update-confirm.hidden,
.mp-pack-update-preview.hidden {
    display: none;
}

.mp-pack-update-confirm-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    margin: 8px 0;
    font-size: 13px;
}

.mp-pack-update-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.mp-pack-update-form-error {
    margin: 10px 0 0;
    font-size: 13px;
    color: #b91c1c;
}

.mp-pack-update-form-error.hidden {
    display: none;
}

.mp-pack-update-apply.mp-pack-update-applying,
.mp-pack-update-apply:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.mp-pack-update-success-lede,
.mp-pack-update-registry-msg {
    margin: 0 0 8px;
    font-size: 14px;
}

.mp-pack-update-failed {
    border-color: #fecaca;
    background: #fef2f2;
}

.mp-pack-update-success {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.mp-pack-update-refresh-note {
    font-size: 12px;
    margin-top: 8px;
}

.mp-pack-update-refresh-warn {
    font-size: 13px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.12);
    color: #92400e;
}

.mp-installed-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    font-size: 14px;
    margin: 16px 0;
}

.mp-read-only-note {
    font-size: 13px;
    margin-top: 12px;
}

.mp-attempt-id {
    display: block;
    font-size: 11px;
    margin-top: 4px;
}

.mp-paid-notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: rgba(234, 88, 12, 0.1);
    color: #9a3412;
    font-size: 14px;
}

.mp-paid-notice i {
    margin-top: 2px;
    color: #ea580c;
}

.mp-paid-notice p {
    margin: 4px 0 0;
    font-weight: 400;
}

.mp-payment-required-panel {
    padding: 8px 4px 0;
    color: var(--text-primary, #0f172a);
}

.mp-payment-required-panel > i {
    color: #ea580c;
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.mp-payment-pack-line {
    margin: 12px 0 4px;
}

.mp-payment-actions {
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 8px;
}

.pack-card-footer .mp-contact-sales {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mp-modal-actions .mp-contact-sales {
    text-decoration: none;
}

.mp-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.mp-modal.hidden {
    display: none;
}

.mp-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mp-modal-panel {
    background: var(--card-bg, #fff);
    border-radius: 16px;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
}

.mp-wizard-panel {
    max-width: 560px;
}

.mp-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    border: none;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted, #64748b);
}

.mp-checklist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin: 12px 0;
}

.mp-checklist-group ul {
    margin: 4px 0 0;
    padding-left: 16px;
    font-size: 12px;
    color: var(--text-muted, #64748b);
}

.mp-reviews {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mp-reviews-loading,
.mp-reviews-empty,
.mp-reviews-error {
    font-size: 13px;
    margin: 0;
}

.mp-reviews-error {
    padding: 12px;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.06);
}

.mp-reviews-error p {
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mp-reviews-empty-inline {
    font-size: 12px;
}

.mp-rating-summary {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.mp-detail-rating {
    margin-top: 4px;
}

.mp-review {
    padding: 12px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    font-size: 13px;
}

.mp-review-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.mp-review-title {
    margin: 0 0 4px;
    font-size: 13px;
}

.mp-review-body {
    margin: 0;
    color: var(--text-muted, #64748b);
    font-size: 13px;
    line-height: 1.45;
}

.mp-review-eligibility {
    margin: 16px 0;
    padding: 14px 16px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    background: var(--surface-muted, #f8fafc);
}

.mp-review-eligibility h4 {
    margin: 0 0 10px;
    font-size: 15px;
}

.mp-review-contract p {
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-muted, #64748b);
}

.mp-review-contract p:last-child {
    margin-bottom: 12px;
}

.mp-review-write-disabled {
    pointer-events: none;
    opacity: 0.72;
}

.mp-review-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mp-review-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

.mp-review-field input,
.mp-review-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    font: inherit;
}

.mp-rating-input {
    border: 0;
    margin: 0;
    padding: 0;
}

.mp-rating-input legend {
    font-size: 13px;
    margin-bottom: 6px;
}

.mp-rating-stars {
    display: flex;
    gap: 4px;
}

.mp-rating-star {
    border: 0;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
}

.mp-rating-star.is-selected {
    color: #eab308;
}

.mp-review-field-error,
.mp-review-form-error {
    margin: 0;
    font-size: 13px;
    color: var(--danger, #dc2626);
}

.mp-review-field-error.hidden,
.mp-review-form-error.hidden {
    display: none;
}

.mp-review-submit.mp-review-submitting,
.mp-review-submit:disabled {
    opacity: 0.65;
    pointer-events: none;
}

.mp-review-success-lede,
.mp-review-duplicate-msg,
.mp-review-ineligible-msg {
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-muted, #64748b);
    margin: 0 0 12px;
}

.mp-review-your-card {
    margin-bottom: 12px;
}

.mp-review-submitted .mp-review-view-catalog,
.mp-review-already-submitted .mp-review-view-catalog {
    margin-top: 4px;
}

.mp-required {
    font-weight: normal;
    color: var(--text-muted, #64748b);
}

.mp-review-eligibility-note {
    font-size: 13px;
    line-height: 1.45;
    margin: 0 0 10px;
}

.mp-reviews-load-more-wrap {
    text-align: center;
    padding-top: 4px;
}

@media (max-width: 640px) {
    .mp-review-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .mp-modal-panel {
        max-height: min(92vh, 900px);
        overflow-y: auto;
    }
}

.mp-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border, #e2e8f0);
}

.mp-wizard-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
    font-size: 11px;
}

.mp-wizard-step {
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--surface-2, #f1f5f9);
    color: var(--text-muted, #64748b);
}

.mp-wizard-step.active {
    background: rgba(99, 102, 241, 0.15);
    color: #4f46e5;
    font-weight: 600;
}

.mp-field {
    display: block;
    margin-bottom: 12px;
}

.mp-field span {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.mp-field input,
.mp-field textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    font-size: 14px;
}

.mp-integration-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mp-integration-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.mp-success {
    text-align: center;
    padding: 20px 0;
}

.mp-success i {
    font-size: 48px;
    color: #16a34a;
}

.mp-success-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

.mp-detail-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 12px;
}

/* ── AI Supervisor panel (Agents module) ── */
.supervisor-panel {
    margin-bottom: 24px;
    padding: 18px 20px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.04), rgba(99, 102, 241, 0.06));
}

.supervisor-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.supervisor-panel h3 {
    margin: 0 0 4px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.supervisor-score-badge {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary, #1e40af);
    text-align: center;
}

.supervisor-score-badge span {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted, #64748b);
}

.supervisor-hint {
    margin: 0 0 12px;
    font-size: 13px;
}

.supervisor-reviews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.supervisor-review-card {
    padding: 12px;
    border-radius: 8px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border, #e2e8f0);
}

.review-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.review-score {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary, #1e40af);
}

.review-grade {
    font-size: 10px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2, #f1f5f9);
}

.review-grade.excellent { background: rgba(22, 163, 74, 0.15); color: #15803d; }
.review-grade.needs_improvement { background: rgba(220, 38, 38, 0.12); color: #b91c1c; }

.review-rec {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted, #64748b);
}

/* ===== AI Command Center ===== */
.command-center-header h1 i { color: var(--primary); margin-right: 8px; }

.command-status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.command-status-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 13px;
}

.command-status-pill.ok { border-color: rgba(16, 185, 129, 0.4); background: rgba(16, 185, 129, 0.06); }
.command-status-pill.warn { border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.06); }

.command-center-grid { margin-top: 24px; }

.command-map-card { min-height: 400px; }

.command-map-wrap {
    position: relative;
    height: 340px;
    margin-top: 12px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(99, 102, 241, 0.25);
    box-shadow:
        inset 0 0 60px rgba(15, 23, 42, 0.6),
        0 8px 32px rgba(15, 23, 42, 0.35);
}

.world-map-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.world-map-svg .map-scan-line {
    animation: mapScan 6s linear infinite;
}

@keyframes mapScan {
    0% { transform: translateY(-60px); opacity: 0; }
    10% { opacity: 0.35; }
    90% { opacity: 0.2; }
    100% { transform: translateY(560px); opacity: 0; }
}

.map-dots-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.map-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    pointer-events: auto;
    cursor: default;
}

.map-dot-core,
.map-dot-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
}

.map-dot-core {
    background: currentColor;
    box-shadow: 0 0 12px currentColor, 0 0 24px currentColor;
    z-index: 2;
}

.map-dot-ring {
    border: 2px solid currentColor;
    opacity: 0.55;
    animation: mapDotRing 2.4s ease-out infinite;
}

.map-dot-lg {
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
}

.map-dot-lg .map-dot-core {
    box-shadow: 0 0 16px currentColor, 0 0 32px currentColor;
}

.map-dot-active { color: #a78bfa; }
.map-dot-waiting { color: #fbbf24; }
.map-dot-escalation { color: #f87171; }

@keyframes mapDotRing {
    0% { transform: scale(0.6); opacity: 0.85; }
    70% { transform: scale(2.6); opacity: 0; }
    100% { transform: scale(2.6); opacity: 0; }
}

.map-legend {
    position: absolute;
    left: 14px;
    bottom: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.2);
    backdrop-filter: blur(8px);
    z-index: 3;
}

.map-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: rgba(226, 232, 240, 0.9);
}

.map-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.map-legend-dot.active {
    background: #a78bfa;
    color: #a78bfa;
}

.map-legend-dot.waiting {
    background: #fbbf24;
    color: #fbbf24;
}

.map-legend-dot.escalation {
    background: #f87171;
    color: #f87171;
}

.plan-card.trial { border-color: rgba(16, 185, 129, 0.4); }
.plan-card .plan-features { font-size: 12px; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }

/* Mission Control console (MC-U-3+) */
.mc-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.mc-crm-body { margin-top: 8px; }
.mc-sarah-context-tag { margin: 0 0 16px; }

.page-content:has(.portal-sarah-page) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 16px 24px 24px;
}

.portal-sarah-page {
    display: grid;
    grid-template-columns: minmax(240px, 300px) 1fr;
    gap: 0;
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-card);
}

.portal-sarah-page-aside {
    padding: 24px 20px;
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
    overflow-y: auto;
}

.portal-sarah-page-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.portal-sarah-page-avatar {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-muted, #f1f5f9);
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--primary, #6366f1) 18%, transparent);
}

.portal-sarah-page-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.portal-sarah-page-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.portal-sarah-page-subtitle {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

.portal-sarah-page-intro {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0 0 12px;
}

.portal-sarah-page-aside-heading {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0 0 10px;
}

.portal-sarah-cap-list,
.portal-sarah-try-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    font-size: 13px;
}

.portal-sarah-cap-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.portal-sarah-cap-list li:last-child { border-bottom: none; }

.portal-sarah-cap-list i {
    width: 18px;
    color: var(--primary);
    text-align: center;
}

.portal-sarah-try-list li {
    padding: 6px 0;
    color: var(--text-muted);
    line-height: 1.4;
}

.portal-sarah-page-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

.portal-sarah-page-main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
}

.portal-sarah-page-main-header strong {
    display: block;
    font-size: 15px;
}

.portal-sarah-page-main-header .text-muted {
    display: block;
    font-size: 12px;
    margin-top: 2px;
    color: var(--text-muted);
    font-weight: 400;
}

.portal-sarah-page-chat.portal-sarah-chat-mount {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.portal-sarah-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.portal-sarah-chat-mount--page .portal-sarah-messages {
    max-height: none;
    padding: 20px 24px;
    gap: 12px;
}

.portal-sarah-msg {
    max-width: min(720px, 85%);
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.portal-sarah-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
}

.portal-sarah-msg.ai {
    align-self: flex-start;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.portal-sarah-msg.typing {
    align-self: flex-start;
    display: flex;
    gap: 6px;
    padding: 14px 18px;
}

.portal-sarah-msg.typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.5;
    animation: mcSarahTyping 1s infinite ease-in-out;
}

.portal-sarah-msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.portal-sarah-msg.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes mcSarahTyping {
    0%, 80%, 100% { transform: scale(0.85); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.portal-sarah-suggestions--inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px 12px;
    flex-shrink: 0;
}

.portal-sarah-chip {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--primary);
    cursor: pointer;
    font-family: inherit;
}

.portal-sarah-chip:hover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.portal-sarah-chat-mount--page .portal-sarah-form {
    padding: 16px 20px 20px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.portal-sarah-form textarea {
    flex: 1;
    min-height: 72px;
    max-height: 200px;
    resize: vertical;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--text-primary);
}

.portal-sarah-send {
    flex-shrink: 0;
    min-height: 44px;
}

@media (max-width: 900px) {
    .portal-sarah-page {
        grid-template-columns: 1fr;
        max-height: none;
    }
    .portal-sarah-page-aside {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 240px;
    }
}

.mc-tenant-chip-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; }
.mc-tenant-chip {
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    max-width: 100%;
    text-align: left;
}
.mc-tenant-chip .panel-hint {
    display: block;
    font-size: 11px;
    word-break: break-all;
    /* Override global .panel-hint negative margin (meant for section leads under headings). */
    margin: 0;
    line-height: 1.3;
}
.mc-tenant-chip:hover { border-color: var(--primary); }
.mc-support-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 8px;
}
.mc-support-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px;
    min-height: 240px;
    box-shadow: var(--shadow);
}
.mc-support-column h4 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 4px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}
.mc-support-column h4 .badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}
.mc-support-column .empty-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    font-size: 13px;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}
.mc-support-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    background: var(--bg-card);
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.mc-support-card:hover {
    border-color: rgba(124, 58, 237, 0.35);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.mc-support-card-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mc-support-card-meta {
    margin: 0;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-muted);
    word-break: break-word;
}
@media (max-width: 1100px) {
    .mc-support-board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .mc-support-board { grid-template-columns: 1fr; }
}

.pi-support-ops { margin: 16px 0; }
.pi-support-ops-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.pi-support-ops .pi-stat {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
}
.pi-support-ops .pi-stat-val { display: block; font-size: 1.25rem; font-weight: 600; }
.pi-support-ops .pi-stat-lbl { font-size: 11px; color: var(--text-muted); }
.mc-audit-row { cursor: pointer; }
.mc-audit-row:hover { background: var(--bg-body); }
.mc-audit-dl { font-size: 13px; }
.mc-audit-dl dt { font-weight: 600; margin-top: 8px; }
.mc-audit-dl dd { margin: 4px 0 0; }

.attention-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.attention-card {
    position: relative;
    border-radius: var(--radius-lg);
    padding: 20px 20px 18px;
    border: 1px solid var(--border-color);
    background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-muted) 100%);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
}
.attention-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}
.attention-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.attention-card--red::before { background: linear-gradient(180deg, #f87171, #dc2626); }
.attention-card--yellow::before { background: linear-gradient(180deg, #fbbf24, #d97706); }
.attention-card--green::before { background: linear-gradient(180deg, #4ade80, #16a34a); }
.attention-card h3 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
    margin: 0 0 10px;
    line-height: 1.35;
}
.attention-count {
    font-size: 2.25rem;
    font-weight: 700;
    margin: 0 0 10px;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.attention-card .pi-panel-hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
}
.attention-meta {
    list-style: none;
    font-size: 12px;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-muted);
}
.attention-meta li {
    display: flex;
    align-items: center;
    gap: 8px;
}
.attention-meta li::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-color);
    flex-shrink: 0;
}
.attention-page .panel-card {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 0;
    overflow: hidden;
    margin-bottom: 20px;
}
.attention-page .panel-card > h3:not(.attention-queue-title) {
    padding: 18px 22px 0;
}
.attention-page .panel-card > .pi-panel-hint,
.attention-page .panel-card > .attention-recurring-list,
.attention-page .panel-card > .table-wrap {
    padding-left: 22px;
    padding-right: 22px;
    padding-bottom: 18px;
}
.attention-queue-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-muted);
}
.attention-queue--red .attention-queue-head {
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.08), transparent);
}
.attention-queue--yellow .attention-queue-head {
    background: linear-gradient(90deg, rgba(217, 119, 6, 0.1), transparent);
}
.attention-queue--green .attention-queue-head {
    background: linear-gradient(90deg, rgba(22, 163, 74, 0.08), transparent);
}
.attention-queue-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.attention-queue-count {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.attention-table-wrap {
    padding: 0 !important;
    overflow-x: auto;
}
.attention-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.attention-data-table th {
    text-align: left;
    padding: 12px 22px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.attention-data-table td {
    padding: 14px 22px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    vertical-align: top;
    line-height: 1.45;
}
.attention-data-table tbody tr:last-child td {
    border-bottom: none;
}
.attention-row {
    cursor: pointer;
    transition: var(--transition);
}
.attention-row:hover td {
    background: var(--primary-glow);
}
.attention-org {
    font-weight: 600;
    color: var(--text-primary);
    max-width: 200px;
}
.attention-issue {
    max-width: 280px;
    color: var(--text-primary);
}
.attention-why {
    max-width: 320px;
    font-size: 12px;
    color: var(--text-muted);
}
.severity-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
}
.severity-pill--critical,
.severity-pill--high {
    background: var(--danger-light);
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.25);
}
.severity-pill--medium {
    background: var(--warning-light);
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.3);
}
.severity-pill--low {
    background: var(--info-light);
    color: #1d4ed8;
    border-color: rgba(59, 130, 246, 0.25);
}
.severity-pill--unknown,
.severity-pill-- {
    background: var(--bg-hover);
    color: var(--text-muted);
}
.attention-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 36px 24px 40px;
    gap: 8px;
    color: var(--text-secondary);
}
.attention-empty-state i {
    font-size: 28px;
    color: var(--success);
    opacity: 0.85;
    margin-bottom: 4px;
}
.attention-empty-state p {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
}
.attention-detail-panel {
    padding: 20px 22px !important;
    margin-top: 8px;
}
.attention-recurring-list {
    font-size: 13px;
    line-height: 1.55;
    margin: 12px 0 0;
    padding-left: 20px;
}

/* Companies table — modern tenant directory */
.companies-table-wrap {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    overflow-x: auto;
}
.companies-table-wrap .table-footer {
    padding: 12px 20px;
    background: var(--bg-muted);
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}
.companies-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(180deg, var(--bg-muted) 0%, var(--bg-card) 100%);
    backdrop-filter: blur(8px);
    padding: 14px 20px;
    font-size: 11px;
    letter-spacing: 0.06em;
}
.companies-table tbody tr.company-row {
    cursor: default;
    transition: var(--transition);
}
.companies-table tbody tr.company-row:hover td {
    background: linear-gradient(90deg, var(--primary-glow), transparent 55%);
}
.companies-table tbody tr.company-row td {
    padding: 16px 20px;
    vertical-align: middle;
}
.companies-table .company-name-text {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.35;
    margin-bottom: 2px;
}
.companies-table .company-name-text .tenant-class-badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: 0.04em;
}
.companies-table .company-table-avatar {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 2px var(--bg-card), var(--shadow);
    flex-shrink: 0;
}
.companies-table .org-name {
    gap: 14px;
}
.company-cross-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.company-cross-links .cross-link,
.company-cross-links .cross-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 4px 10px;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    line-height: 1.2;
}
.company-cross-links .cross-link:hover,
.company-cross-links .cross-link-btn:hover {
    color: var(--primary);
    border-color: rgba(124, 58, 237, 0.35);
    background: var(--primary-glow);
    text-decoration: none;
    transform: translateY(-1px);
}
.companies-table .wa-cell {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    border: 1px solid var(--border-light);
}
.companies-table .wa-cell.wa-active {
    background: var(--success-light);
    border-color: rgba(16, 185, 129, 0.25);
}
.companies-table .col-actions .action-menu-trigger {
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.companies-table .col-actions .action-menu-trigger:hover {
    background: var(--bg-hover);
}

@media (max-width: 900px) {
    .attention-data-table th:nth-child(4),
    .attention-data-table td:nth-child(4) {
        display: none;
    }
}
