/* ============================================================
   WHITE MOUNTAIN CATALOG — ENTERPRISE THEME
   ============================================================
   Stack  : Bootstrap 5.3 + Bootstrap Icons + Alpine.js
   Fonts  : Inter (Google Fonts)

   ┌─────────────────────────────────────────────────────────┐
   │  THEME CONFIGURATION — change these to retheme the app  │
   └─────────────────────────────────────────────────────────┘ */

:root {
    /* ── Primary brand color (Intuceo Blue) ───────────────────── */
    --brand-50:    #eef6fe;
    --brand-100:   #dcebfc;
    --brand-200:   #afd2f9;
    --brand-300:   #71b0f4;
    --brand-400:   #4296f0;
    --brand-500:   #2385ed;
    --brand-600:   #1276e1;   /* ← main accent — Intuceo brand blue */
    --brand-700:   #0e5eb4;
    --brand-800:   #0c4c90;
    --brand-900:   #09396c;

    /* ── Legacy Aliases ──────────────────────────────────── */
    --blue-50:     var(--brand-50);
    --blue-100:    var(--brand-100);
    --blue-500:    var(--brand-500);
    --blue-600:    var(--brand-600);
    --blue-700:    var(--brand-700);

    /* ── Sidebar (Enterprise Light) ───────────────────────── */
    --sidebar-bg:          #0a0a0a;   /* ← Intuceo-style near-black */
    --sidebar-border:      rgba(255, 255, 255, 0.08);   /* ← Subtle border separator */
    --sidebar-text:        #94a3b8;   /* ← Visible light-slate text on dark */
    --sidebar-active-bg:   rgba(18, 118, 225, 0.16);
    --sidebar-active-text: var(--brand-400);
    --sidebar-active-border: var(--brand-500);
    --sidebar-width:       260px;

    /* ── App surface ─────────────────────────────────────── */
    --app-bg:      #f8fafc;   /* ← refined background color */
    --topbar-bg:   #0a0a0a;   /* ← Intuceo-style near-black */

    /* ── Re-wire Bootstrap primary ───────────────────────── */
    --bs-primary:            var(--brand-600);
    --bs-primary-rgb:        18, 118, 225;
    --bs-link-color:         var(--brand-600);
    --bs-link-hover-color:   var(--brand-700);
    --bs-border-radius:      0.5rem;
    --bs-border-radius-lg:   0.75rem;
    --bs-border-radius-xl:   1rem;
    --bs-border-radius-2xl:  1.25rem;
    --bs-body-font-family:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bs-body-bg:            var(--app-bg);
    --bs-body-color:         #0f172a;
    --bs-body-font-size:     0.875rem;
    --bs-body-line-height:   1.6;
    --bs-border-color:       #e2e8f0;
    --bs-secondary-bg:       #f8fafc;

    /* ── Shadows (Layered & Diffuse) ─────────────────────── */
    --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm:  0 2px 4px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.05);
    --shadow:     0 4px 12px -2px rgba(0,0,0,0.08), 0 2px 6px -1px rgba(0,0,0,0.04);
    --shadow-md:  0 12px 24px -4px rgba(0,0,0,0.09), 0 4px 8px -2px rgba(0,0,0,0.05);
    --shadow-lg:  0 24px 48px -8px rgba(0,0,0,0.12), 0 8px 16px -4px rgba(0,0,0,0.06);
    --shadow-xl:  0 32px 64px -12px rgba(0,0,0,0.16);

    /* ── Glassmorphism ───────────────────────────────────── */
    --glass-bg:          rgba(255, 255, 255, 0.75);
    --glass-bg-dark:     rgba(15, 23, 42, 0.75);
    --glass-border:      rgba(255, 255, 255, 0.12);
    --glass-blur:        12px;

    /* ── Status ──────────────────────────────────────────── */
    --success:        #059669;
    --success-light:  #d1fae5;
    --warning:        #d97706;
    --warning-light:  #fef3c7;
    --danger:         #dc2626;
    --danger-light:   #fee2e2;

    /* ── Gray scale (Slate) ─────────────────────────────── */
    --gray-50:   #f8fafc;
    --gray-100:  #f1f5f9;
    --gray-200:  #e2e8f0;
    --gray-300:  #cbd5e1;
    --gray-400:  #94a3b8;
    --gray-500:  #64748b;
    --gray-600:  #475569;
    --gray-700:  #334155;
    --gray-800:  #1e293b;
    --gray-900:  #0f172a;

    /* ── Purple palette ─────────────────────────────────── */
    --purple-50:   #f5f3ff;
    --purple-100:  #ede9fe;
    --purple-200:  #ddd6fe;
    --purple-300:  #c4b5fd;
    --purple-400:  #a78bfa;
    --purple-500:  #8b5cf6;
    --purple-600:  #7c3aed;
    --purple-700:  #6d28d9;
    --purple-800:  #5b21b6;
    --purple-900:  #4c1d95;

    /* ── Red/Success Aliases ────────────────────────────── */
    --red-50:    var(--danger-light);
    --red-600:   var(--danger);
    --green-50:  var(--success-light);
    --green-600: var(--success);

    /* ── Aliases ────────────────────────────────────────── */
    --primary:        var(--brand-600);
    --primary-dark:   var(--brand-700);
    --primary-light:  var(--brand-50);

    /* ── Navbar ──────────────────────────────────────────── */
    --navbar-height: 64px;
}

/* ── Glassmorphism Utilities ── */
.glass {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur)) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur)) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.glass-dark {
    background: var(--glass-bg-dark) !important;
    backdrop-filter: blur(var(--glass-blur)) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur)) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--bs-body-font-family);
    background: var(--app-bg);
    color: var(--bs-body-color);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.035em;
    font-weight: 700;
}


/* ════════════════════════════════════════════════════════════
   BOOTSTRAP OVERRIDES — buttons, forms, cards, tables, badges
   ════════════════════════════════════════════════════════════ */

/* ── Primary btn ── */
.btn-primary {
    --bs-btn-bg:            var(--brand-600);
    --bs-btn-border-color:  var(--brand-600);
    --bs-btn-hover-bg:      var(--brand-700);
    --bs-btn-hover-border-color: var(--brand-700);
    --bs-btn-active-bg:     var(--brand-800);
    --bs-btn-active-border-color: var(--brand-800);
    --bs-btn-focus-shadow-rgb: 0, 102, 255;
    box-shadow: 0 4px 12px rgba(18, 118, 225, 0.2);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.btn-primary:hover { 
    box-shadow: 0 6px 16px rgba(18, 118, 225, 0.35); 
    transform: translateY(-2px); 
}
.btn-primary:active { transform: translateY(0); }

/* ── Secondary btn ── */
.btn-secondary {
    --bs-btn-bg:            #ffffff;
    --bs-btn-color:         var(--gray-700);
    --bs-btn-border-color:  var(--gray-200);
    --bs-btn-hover-bg:      var(--gray-50);
    --bs-btn-hover-color:   var(--gray-900);
    --bs-btn-hover-border-color: var(--gray-300);
    --bs-btn-active-bg:     var(--gray-100);
    font-weight: 600;
}

/* ── Warning btn (used for the Edit action — muted tint of the brand blue) ── */
.btn-warning {
    --bs-btn-bg:            var(--brand-50);
    --bs-btn-color:         var(--brand-700);
    --bs-btn-border-color:  var(--brand-100);
    --bs-btn-hover-bg:      var(--brand-100);
    --bs-btn-hover-border-color: var(--brand-200);
    --bs-btn-hover-color:   var(--brand-800);
    --bs-btn-active-bg:     var(--brand-200);
    font-weight: 600;
}

/* ── Danger btn ── */
.btn-danger {
    --bs-btn-bg:            #fff1f2;
    --bs-btn-color:         var(--danger);
    --bs-btn-border-color:  #fecdd3;
    --bs-btn-hover-bg:      #ffe4e6;
    --bs-btn-hover-border-color: #fca5a5;
    --bs-btn-hover-color:   var(--danger);
    --bs-btn-active-bg:     #fecdd3;
    font-weight: 600;
}

/* ── Shared btn ── */
.btn {
    font-family: inherit;
    letter-spacing: 0.01em;
    transition: all 0.15s ease;
}

.btn:active { transform: scale(0.97); }

/* ── Sync ACLs Button ── */
.btn-sync-acls {
    position: relative;
    overflow: hidden;
}

.btn-sync-acls i {
    display: inline-block;
    transition: transform 0.3s ease;
}

.btn-sync-acls:hover i {
    animation: spin 1.5s linear infinite;
}

/* ── Forms ── */
.form-control, .form-select {
    font-family: inherit;
    font-size: 0.875rem;
    border-color: var(--gray-200);
    border-width: 1.5px;
    color: var(--gray-900);
    padding: 0.575rem 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-600);
    box-shadow: 0 0 0 3px rgba(18, 118, 225,0.1);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}

/* Keep .form-group working (Bootstrap 5 removed it) */
.form-group { margin-bottom: 1.125rem; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
}

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

/* ── Cards ── */
.card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--bs-border-radius-xl);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* ── Badges (Professional & Unified) ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
}

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-primary, .badge-brand {
    background: var(--brand-50);
    color: var(--brand-600);
}

.badge-success {
    background: #dcfce7;
    color: #15803d;
}

.badge-warning {
    background: #fef9c3;
    color: #a16207;
}

.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-purple {
    background: #f3e8ff;
    color: #7e22ce;
}

.badge-info {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-sm { padding: 0.15rem 0.45rem; font-size: 0.65rem; }

.badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-100);
    padding: 0.75rem 1.125rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-header h2 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.01em;
    margin: 0;
}

.card-body { padding: 1.125rem; }

.icon-only-btn {
    width: 32px;
    height: 32px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    border-radius: 8px;
    flex-shrink: 0;
    transition: all 0.15s;
}
.icon-only-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Custom Premium Tooltip — shared across pages via [data-tooltip] (see the
   tooltip-engine IIFE near the end of base.html's shared <script> block).
   This used to be a pure-CSS ::after/::before pseudo-element on the trigger
   itself, but that gets clipped by any scrollable/overflow ancestor (e.g.
   .table-wrapper's overflow-x:auto also forces overflow-y to auto per the
   CSS overflow spec — you can't mix one axis 'visible' with the other
   non-visible on the same element). Rendering a single real element fixed
   to the viewport and positioned via JS on hover sidesteps that entirely.
   tooltip-left/tooltip-right/tooltip-wrap remain marker classes read by the
   JS — same attribute/class contract as before, so no template changes. */
.dt-tooltip {
    position: fixed;
    z-index: 100000;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(4px);
    color: #f8fafc;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.725rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --dt-arrow-left: 50%;
}

.dt-tooltip.dt-tooltip--visible {
    opacity: 1;
    transform: scale(1);
}

.dt-tooltip.dt-tooltip--wrap {
    white-space: normal;
    max-width: 240px;
    line-height: 1.4;
}

.dt-tooltip::after {
    content: "";
    position: absolute;
    left: var(--dt-arrow-left);
    top: 100%;
    transform: translateX(-50%);
    border-width: 5px 5px 0 5px;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.95) transparent transparent transparent;
}

/* Flipped below the trigger when there isn't room above (e.g. top table row) */
.dt-tooltip.dt-tooltip--flip::after {
    top: auto;
    bottom: 100%;
    border-width: 0 5px 5px 5px;
    border-color: transparent transparent rgba(15, 23, 42, 0.95) transparent;
}

/* ── Tables ── */
.table {
    --bs-table-color:       var(--gray-700);
    --bs-table-bg:          transparent;
    --bs-table-hover-bg:    var(--gray-50);
    --bs-table-border-color: var(--gray-100);
    font-size: 0.875rem;
}

.table th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.065em;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom-width: 1px;
    padding: 0.65rem 1.25rem;
    white-space: nowrap;
}

.table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}
.table thead { display: table-header-group; }
.table tbody { display: table-row-group; }
.table td, .table th {
    padding: 0.85rem 0.75rem;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table th { padding: 0.85rem 0.75rem; }
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }

/* Hide Tags and Classification for assets table */
.assets-table th:nth-child(5),
.assets-table td:nth-child(5) {
    display: none;
}
.assets-table th:nth-child(7),
.assets-table td:nth-child(7) {
    display: none;
}
.table-empty { text-align: center; color: var(--gray-400); padding: 3.5rem !important; }

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

.table tbody tr:hover {
    background-color: var(--gray-50);
}

/* ── Badges — keep our semantic names ── */
.badge {
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.01em;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
}

/* Map our domain/status badge colours */
.badge-purple { background: #ede9fe !important; color: #5b21b6 !important; }
.badge-blue   { background: #dbeafe !important; color: #1d4ed8 !important; }
.badge-green  { background: #d1fae5 !important; color: #065f46 !important; }
.badge-yellow { background: #fef3c7 !important; color: #92400e !important; }
.badge-red    { background: #fee2e2 !important; color: #991b1b !important; }
.badge-gray   { background: var(--gray-100) !important; color: var(--gray-600) !important; }
.badge-orange { background: #fff7ed !important; color: #9a3412 !important; }
.badge-rose   { background: #fef2f2 !important; color: #9f1239 !important; }
.badge-pink   { background: #fce7f3 !important; color: #9d174d !important; }
.badge-teal   { background: #ccfbf1 !important; color: #115e59 !important; }

/* ── Modals & Overlays (Consolidated) ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.2s ease, visibility 0s;
    visibility: visible;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    display: none !important;
}

.modal-box {
    background: white;
    border-radius: var(--bs-border-radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 1061;
}

@keyframes modal-pop {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-confirm-box { max-width: 420px; }
.modal-input-box { max-width: 480px; }

.modal-box .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
}

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

.modal-box .modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

.modal-box .modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
    border-radius: 0 0 var(--bs-border-radius-xl) var(--bs-border-radius-xl);
}

.modal-text { margin: 0; color: var(--gray-600); font-size: 0.9rem; line-height: 1.6; }

/* Override Bootstrap's .btn-close SVG with our ✕ text approach */
.btn-close, .modal-box .btn-close {
    background-image: none;
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--bs-border-radius-sm);
    color: var(--gray-400);
    opacity: 1;
    font-size: 1rem;
    transition: all 0.14s;
    background: none;
    border: none;
    cursor: pointer;
}

.btn-close:hover { color: var(--gray-700); background: var(--gray-100); opacity: 1; }

/* ── Alerts — keep our class names ── */
.alert { font-weight: 500; font-size: 0.875rem; border-radius: var(--bs-border-radius); }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

/* ── Pagination ── */
.asset-pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.875rem 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
    border-top: 1px solid var(--gray-100);
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.6rem;
    border: 1.5px solid var(--gray-200);
    border-radius: 7px;
    background: white;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    color: var(--gray-600);
    transition: all 0.14s;
    white-space: nowrap;
    gap: 0.3rem;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--brand-50);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(18, 118, 225,0.3);
    cursor: default;
}

.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    font-size: 0.82rem;
    color: var(--gray-400);
    letter-spacing: 0.05em;
}

.page-info {
    font-size: 0.78rem;
    color: var(--gray-400);
    margin-right: 0.5rem;
    white-space: nowrap;
}

/* ── Misc helpers ── */
.hidden { display: none !important; }

.search-input {
    padding: 0.575rem 0.875rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--bs-border-radius);
    font-size: 0.875rem;
    font-family: inherit;
    background: white;
    color: var(--gray-800);
    transition: all 0.14s;
    min-width: 200px;
}

.search-input::placeholder { color: var(--gray-400); }
.search-input:hover { border-color: var(--gray-300); }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(18, 118, 225,0.1); }

.filter-select-dropdown {
    padding: 0.575rem 2rem 0.575rem 0.875rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--bs-border-radius);
    font-size: 0.875rem;
    font-family: inherit;
    background: white;
    cursor: pointer;
    transition: all 0.14s;
    color: var(--gray-700);
    font-weight: 500;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 8l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
}

.filter-select-dropdown:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(18, 118, 225,0.1); }

.access-info {
    font-size: 0.72rem;
    color: var(--gray-500);
    padding: 0.18rem 0.55rem;
    background: var(--gray-100);
    border-radius: 20px;
    font-weight: 500;
}

.filter-bar { 
    display: flex; 
    gap: 0.6rem; 
    flex-wrap: wrap; 
    margin-bottom: 1.5rem; 
    align-items: center; 
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.filter-btn {
    padding: 0.45rem 1rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    font-size: 0.825rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-btn:hover { 
    background: rgba(18, 118, 225, 0.05);
    color: var(--brand-600); 
}

.filter-btn.active { 
    background: var(--brand-600); 
    color: white; 
    box-shadow: 0 4px 12px rgba(18, 118, 225, 0.2);
}

.filters-row { display: flex; align-items: center; gap: 0.5rem; flex: 1; flex-wrap: wrap; min-width: 0; }

.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--brand-50);
    color: var(--primary);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.78rem;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }

/* Premium Shimmer Loading Effect */
.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.4) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    background-color: var(--gray-100);
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeIn  { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }

.shimmer {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer-anim 1.5s infinite;
    display: inline-block;
}

@keyframes shimmer-anim { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

.perm-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--bs-border-radius);
    cursor: pointer;
    font-size: 0.82rem;
    transition: border-color 0.14s, background 0.14s;
    color: var(--gray-700);
}

.perm-item:hover { border-color: var(--primary); background: var(--brand-50); }
.perm-item input { accent-color: var(--primary); }

.permissions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }


/* ════════════════════════════════════════════════════════════
   APP LAYOUT
   ════════════════════════════════════════════════════════════ */

.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 300;
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    border-right: 1px solid var(--sidebar-border);
    overflow: hidden;
    /* Apply glass foundation */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.sidebar-brand {
    height: var(--navbar-height);
    padding: 0 1.375rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-logo {
    height: clamp(38px, 3.6vw, 46px);
    width: auto;
    max-width: 100%;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sidebar-brand:hover .brand-logo {
    transform: scale(1.04);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.625rem 0 1rem;
    scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section {
    padding: 1rem 1.375rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--brand-400); /* Highlighted brand color */
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-section::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.125rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: none;
    background: none;
    width: calc(100% - 1.5rem);
    margin: 0.125rem 0.75rem;
    border-radius: 10px;
    letter-spacing: 0.005em;
}

.nav-item:hover {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    text-decoration: none;
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--brand-600);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(18, 118, 225, 0.25);
}

.nav-item .icon {
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    opacity: 0.7;
    transition: transform 0.2s;
}

.nav-item:hover .icon {
    transform: scale(1.15);
    opacity: 1;
}

.nav-item.active .icon { opacity: 1; }

.nav-agent-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
}

.sidebar-footer {
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.03);
}

.user-info { 
    display: flex; 
    align-items: center; 
    gap: 0.65rem; 
    padding: 0.5rem;
    border-radius: 12px;
}

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
    color: white;
    box-shadow: 0 2px 5px rgba(18, 118, 225,0.2);
}

.user-details { flex: 1; min-width: 0; }

.user-name {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--gray-100);
}

.user-role { font-size: 0.68rem; color: var(--gray-400); margin-top: 0.1rem; }

.btn-icon {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    transition: all 0.14s;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.btn-icon:hover { color: var(--danger); background: var(--danger-light); }

.sidebar-footer .btn-icon:hover { background: rgba(220, 38, 38, 0.15); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 299;
    backdrop-filter: blur(1px);
}

/* ── Main content ── */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-200) transparent;
}

.main-content::-webkit-scrollbar { width: 5px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

/* ── Topbar ── */

.topbar {
    height: var(--navbar-height);
    background: rgba(10, 10, 10, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 200;
    gap: 1rem;
    flex-shrink: 0;
}

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

.topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-100);
    letter-spacing: -0.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    color: var(--gray-400);
    font-size: 1.2rem;
    line-height: 1;
    align-items: center;
    justify-content: center;
    transition: all 0.14s;
}

.menu-toggle:hover { background: rgba(255, 255, 255, 0.08); color: var(--gray-100); }

.page-body { padding: 1.25rem; flex: 1; }

.footer {
    text-align: center;
    padding: 1.25rem;
    color: var(--gray-400);
    font-size: 0.75rem;
    border-top: 1px solid var(--gray-100);
    background: white;
    margin-top: auto;
}


/* ════════════════════════════════════════════════════════════
   STATS
   ════════════════════════════════════════════════════════════ */

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

.stat-card {
    background: white;
    border-radius: var(--bs-border-radius-lg);
    padding: 1.125rem 1.25rem;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.15s, transform 0.15s;
}

.stat-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.stat-card .stat-label {
    font-size: 0.72rem;
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.065em;
    margin-bottom: 0.75rem;
}

.stat-card .stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.035em;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-card .stat-sub { font-size: 0.78rem; color: var(--gray-400); }

.stat-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.stat-icon.purple { background: #ede9fe; }
.stat-icon.green  { background: #d1fae5; }
.stat-icon.yellow { background: #fef3c7; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.rose   { background: #ffe4e6; }


/* ════════════════════════════════════════════════════════════
   DOMAIN COMPONENTS
   ════════════════════════════════════════════════════════════ */

.domain-breakdown { display: flex; flex-wrap: wrap; gap: 0.75rem; padding: 1.25rem; }

.domain-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.625rem 1rem;
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    text-decoration: none;
    color: var(--gray-800);
    transition: all 0.14s;
    background: white;
    font-weight: 500;
}

.domain-card:hover { border-color: var(--primary); background: var(--brand-50); transform: translateY(-1px); text-decoration: none; }
.domain-icon { font-size: 1.1rem; }
.domain-name { font-size: 0.875rem; font-weight: 600; text-transform: capitalize; }
.domain-count { margin-left: auto; background: var(--gray-100); color: var(--gray-600); font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 20px; }


/* ════════════════════════════════════════════════════════════
   SEARCH HERO
   ════════════════════════════════════════════════════════════ */

.search-hero {
    background: linear-gradient(145deg, var(--gray-900) 0%, var(--gray-800) 55%, var(--brand-800) 100%);
    border-radius: var(--bs-border-radius-xl);
    padding: 2.75rem 2.5rem;
    margin-bottom: 1.5rem;
    color: white;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.search-hero::before {
    content: '';
    position: absolute;
    top: -40%; right: -8%;
    width: 380px; height: 380px;
    background: radial-gradient(circle, rgba(18, 118, 225,0.22) 0%, transparent 65%);
    pointer-events: none;
}

.search-hero h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.5rem; letter-spacing: -0.025em; }
.search-hero p { opacity: 0.6; margin-bottom: 1.5rem; font-size: 0.9rem; }

.search-box {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 10px;
    padding: 0.35rem 0.35rem 0.35rem 1rem;
    max-width: 560px;
    margin: 0 auto;
    gap: 0.5rem;
    box-shadow: var(--shadow-lg);
}

.search-icon { font-size: 1rem; color: var(--gray-400); }

.search-hero-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    color: var(--gray-800);
    font-family: inherit;
    background: transparent;
}

.access-banner {
    margin-top: 1.25rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--bs-border-radius);
    padding: 0.5rem 1rem;
    font-size: 0.82rem;
    display: inline-block;
}

.search-result-grid { display: flex; flex-direction: column; gap: 0.75rem; }

.search-result-card {
    background: white;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--bs-border-radius-lg);
    padding: 1.25rem 1.5rem;
    transition: all 0.14s;
}

.search-result-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(18, 118, 225,0.1); }
.result-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; }
.result-name { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.25rem; color: var(--gray-900); }
.result-desc { font-size: 0.8rem; color: var(--gray-400); }
.result-score { font-size: 0.75rem; font-weight: 700; color: var(--primary); background: var(--brand-50); padding: 0.2rem 0.5rem; border-radius: 6px; flex-shrink: 0; }
.result-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.search-loading,.search-empty { text-align: center; padding: 3rem; color: var(--gray-400); }
.search-empty h3 { margin: 0.75rem 0 0.5rem; color: var(--gray-600); font-weight: 600; }
.search-meta { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; font-size: 0.875rem; color: var(--gray-600); }
.search-filters { margin-bottom: 1rem; }


/* ════════════════════════════════════════════════════════════
   LINEAGE
   ════════════════════════════════════════════════════════════ */

.lineage-layout { display: grid; grid-template-columns: 300px 1fr; gap: 1.5rem; align-items: start; }
.lineage-sidebar { display: flex; flex-direction: column; }
.asset-list-item { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.25rem; cursor: pointer; border-bottom: 1px solid var(--gray-100); transition: background 0.12s; font-size: 0.875rem; }
.asset-list-item:hover { background: var(--gray-50); }
.asset-list-item.active { background: var(--brand-50); color: var(--primary); }
.asset-list-name { font-weight: 500; }
.graph-layout { display: flex; align-items: center; justify-content: center; gap: 1.5rem; padding: 2rem; width: 100%; }
.graph-column { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.graph-arrow { text-align: center; color: var(--gray-300); font-size: 1.25rem; }
.graph-arrow-h { color: var(--gray-300); font-size: 1.5rem; }
.graph-node { transition: transform 0.15s; }
.graph-node:hover { transform: translateY(-2px); }


/* ════════════════════════════════════════════════════════════
   CHAT
   ════════════════════════════════════════════════════════════ */

.chat-layout {
    display: grid;
    grid-template-columns: 1fr;
    height: calc(100vh - var(--navbar-height) - 3.5rem);
    min-height: 0;
}

.chat-left { display: flex; flex-direction: column; gap: 1rem; min-height: 0; overflow-y: auto; }

.chat-panel {
    background: white;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--bs-border-radius-lg);
    padding: 1rem 1.125rem;
    box-shadow: var(--shadow-xs);
}

.chat-panel-title { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--gray-400); margin-bottom: 0.75rem; }

.domain-pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.18rem 0.55rem; background: var(--brand-50); color: var(--primary); border-radius: 20px; font-size: 0.7rem; font-weight: 600; margin: 0.2rem 0.2rem 0 0; }

.starters-list { display: flex; flex-direction: column; gap: 0.35rem; max-height: 260px; overflow-y: auto; }

.starter-btn { text-align: left; padding: 0.5rem 0.75rem; border: 1.5px solid var(--gray-200); border-radius: var(--bs-border-radius); background: var(--gray-50); font-size: 0.8rem; font-family: inherit; cursor: pointer; color: var(--gray-600); transition: all 0.14s; line-height: 1.4; width: 100%; }
.starter-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--brand-50); }

.source-card { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.6rem; border-radius: var(--bs-border-radius); background: var(--gray-50); border: 1px solid var(--gray-100); margin-bottom: 0.5rem; animation: fadeIn 0.25s ease both; }
.source-rank { width: 20px; height: 20px; border-radius: 50%; background: var(--primary); color: white; font-size: 0.62rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.source-info { flex: 1; min-width: 0; }
.source-name { font-size: 0.78rem; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 0.2rem; }
.source-score { font-size: 0.7rem; font-weight: 700; color: var(--success); }
.sources-placeholder { font-size: 0.8rem; color: var(--gray-400); padding: 0.5rem 0; }

.msg-sources { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--gray-100); }

/* Follow-up suggestions: a separate chip row below the message row (not inside
   .msg-bubble) so they read as a suggested next action, not part of the answer. */
.chat-followups { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0 0.75rem 2.375rem; animation: fadeIn 0.25s ease both; }
.followup-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1.5px solid var(--gray-200);
    background: #ffffff;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.14s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.followup-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--brand-50); }
.sources-toggle { display: inline-flex; align-items: center; gap: 5px; background: none; border: none; cursor: pointer; font-size: 0.72rem; font-weight: 600; color: var(--gray-400); padding: 0; transition: color 0.14s; font-family: inherit; }
.sources-toggle:hover { color: var(--primary); }
.src-chevron { display: inline-block; transition: transform 0.2s; font-style: normal; }
.msg-sources.open .src-chevron { transform: rotate(180deg); }
.sources-list { display: none; flex-direction: column; margin-top: 8px; }
.msg-sources.open .sources-list { display: flex; }

.source-chip { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--bs-border-radius); background: var(--gray-50); border: 1px solid var(--gray-100); font-size: 0.75rem; transition: border-color 0.14s, background 0.14s; text-decoration: none; color: inherit; cursor: pointer; font-family: inherit; text-align: left; width: 100%; }
.source-chip:hover { border-color: var(--primary); background: var(--brand-50); }
.src-rank { width: 18px; height: 18px; border-radius: 50%; background: var(--primary); color: white; font-size: 0.6rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.src-name { flex: 1; font-weight: 500; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.src-domain { font-size: 0.65rem; font-weight: 600; white-space: nowrap; flex-shrink: 0; padding: 1px 6px; border-radius: 10px; }
.src-score { font-size: 0.68rem; font-weight: 700; color: var(--success); white-space: nowrap; flex-shrink: 0; }
.src-link-icon { font-size: 0.7rem; color: var(--gray-400); flex-shrink: 0; opacity: 0; transition: opacity 0.14s; }
.source-chip:hover .src-link-icon { opacity: 1; }

.chat-main { display: flex; flex-direction: column; background: white; border-radius: var(--bs-border-radius-xl); border: 1.5px solid var(--gray-200); overflow: hidden; min-height: 0; box-shadow: var(--shadow-sm); }

.chat-topbar { display: flex; align-items: center; justify-content: space-between; padding: 0.875rem 1.5rem; border-bottom: 1px solid var(--gray-100); flex-shrink: 0; background: var(--gray-50); }
.chat-topbar-left { display: flex; align-items: center; gap: 0.75rem; }
.bot-icon-lg { width: 36px; height: 36px; background: linear-gradient(135deg, var(--primary), #4f46e5); border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.bot-avatar-wrap { position: relative; width: 36px; height: 36px; flex-shrink: 0; }
.bot-avatar-wrap .avatar-face { display: none; width: 36px; height: 36px; border-radius: 50%; }
.bot-avatar-wrap.grace-mode #botIconLg { display: none; }
.bot-avatar-wrap.grace-mode[data-gender="female"] .avatar-female { display: block; }
.bot-avatar-wrap.grace-mode[data-gender="male"] .avatar-male { display: block; }
.avatar-eye { transform-origin: center; animation: avatarBlink 5s infinite; }
.avatar-mouth { transform-origin: center; }
.bot-avatar-wrap.speaking .avatar-mouth { animation: avatarTalk 0.32s ease-in-out infinite; }
@keyframes avatarBlink { 0%, 96%, 100% { transform: scaleY(1); } 98% { transform: scaleY(0.1); } }
@keyframes avatarTalk { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1); } }
.avatar-gender-btn { display: none; position: absolute; bottom: -3px; right: -3px; width: 15px; height: 15px; border-radius: 50%; background: white; border: 1px solid var(--gray-200); font-size: 0.55rem; line-height: 1; cursor: pointer; align-items: center; justify-content: center; padding: 0; color: var(--gray-500); box-shadow: var(--shadow-sm); }
.bot-avatar-wrap.grace-mode .avatar-gender-btn { display: flex; }
.avatar-gender-btn:hover { background: var(--gray-50); color: var(--primary); }
.chat-topbar-title { font-size: 0.9rem; font-weight: 700; color: var(--gray-900); }
.chat-topbar-sub { font-size: 0.7rem; color: var(--gray-400); margin-top: 0.1rem; }

.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; scroll-behavior: smooth; min-height: 0; }
.chat-welcome { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    text-align: center; 
    padding: 4rem 2rem; 
}
.welcome-icon { 
    font-size: 4rem; 
    margin-bottom: 1.5rem; 
    filter: drop-shadow(0 8px 24px rgba(18, 118, 225, 0.15));
}
.chat-welcome h3 { 
    font-size: 1.5rem; 
    font-weight: 800; 
    margin-bottom: 0.75rem; 
    color: var(--gray-900); 
    letter-spacing: -0.035em;
}
.chat-welcome p { 
    color: var(--gray-500); 
    font-size: 1rem; 
    line-height: 1.7; 
    margin-bottom: 2rem; 
    max-width: 420px; 
}
.welcome-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

.msg-row { display: flex; align-items: flex-end; gap: 0.6rem; }
.msg-user { flex-direction: row-reverse; }
.msg-avatar-sm { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; flex-shrink: 0; }
.user-av { background: var(--primary); color: white; }
.bot-av  { background: var(--gray-100); color: var(--gray-500); }
.msg-bubble { 
    max-width: 100%; 
    padding: 0.9rem 1.25rem; 
    border-radius: 1.25rem; 
    font-size: 0.9rem; 
    line-height: 1.6; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.msg-bubble-user { 
    background: linear-gradient(135deg, var(--brand-600), var(--brand-500)); 
    color: white; 
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(18, 118, 225, 0.2);
}

.msg-bubble-bot { 
    background: #ffffff; 
    border: 1px solid rgba(0, 0, 0, 0.05); 
    border-bottom-left-radius: 4px; 
    color: var(--gray-800); 
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.msg-bubble-error { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.msg-time { font-size: 0.66rem; color: var(--gray-400); margin-top: 0.35rem; }

.cursor-blink { display: inline-block; animation: blink 0.7s infinite; color: var(--primary); font-weight: 700; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

.typing-dots { display: flex; gap: 0.35rem; padding: 0.3rem 0; align-items: center; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--gray-300); animation: bounce 1.4s ease-in-out infinite both; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 
    30% { transform: translateY(-4px); opacity: 1; } 
}

code { background: rgba(0,0,0,0.055); padding: 0.1rem 0.35rem; border-radius: 4px; font-family: 'SF Mono','Fira Code','Consolas',monospace; font-size: 0.84em; }

/* Markdown elements rendered via marked.js inside chat answer bubbles */
.msg-bubble-bot ul, .msg-bubble-bot ol { margin: 0.4rem 0; padding-left: 1.4rem; }
.msg-bubble-bot li { margin: 0.2rem 0; }
.msg-bubble-bot li > ul, .msg-bubble-bot li > ol { margin: 0.2rem 0; }
.msg-bubble-bot h1, .msg-bubble-bot h2, .msg-bubble-bot h3,
.msg-bubble-bot h4, .msg-bubble-bot h5, .msg-bubble-bot h6 {
    margin: 0.6rem 0 0.3rem; line-height: 1.3; font-weight: 700; color: var(--gray-800);
}
.msg-bubble-bot h1 { font-size: 1.25rem; }
.msg-bubble-bot h2 { font-size: 1.15rem; }
.msg-bubble-bot h3 { font-size: 1.05rem; }
.msg-bubble-bot h4, .msg-bubble-bot h5, .msg-bubble-bot h6 { font-size: 0.95rem; }
.msg-bubble-bot p { margin: 0.4rem 0; }
.msg-bubble-bot a { color: var(--brand-600); text-decoration: underline; }
.msg-bubble-bot pre { background: rgba(0,0,0,0.05); padding: 0.6rem 0.8rem; border-radius: 8px; overflow-x: auto; margin: 0.5rem 0; }
.msg-bubble-bot pre code { background: none; padding: 0; }
.msg-bubble-bot table { border-collapse: collapse; margin: 0.6rem 0; width: 100%; font-size: 0.85em; overflow-x: auto; display: block; }
.msg-bubble-bot th, .msg-bubble-bot td { border: 1px solid var(--gray-200); padding: 0.35rem 0.6rem; text-align: left; }
.msg-bubble-bot th { background: var(--gray-50); font-weight: 700; }
.msg-bubble-bot blockquote { border-left: 3px solid var(--gray-200); margin: 0.5rem 0; padding: 0.1rem 0.9rem; color: var(--gray-600); }

.chat-chart-wrap { max-width: 480px; margin: 0.6rem 0; }
.chat-chart { max-width: 100%; }

.chat-input-wrapper { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-100); flex-shrink: 0; background: white; }
.chat-input-outer { display: flex; align-items: flex-end; gap: 0.5rem; background: white; border: 1.5px solid var(--gray-200); border-radius: 12px; padding: 0.65rem 0.65rem 0.65rem 1rem; transition: border 0.15s, box-shadow 0.15s; }
.chat-input-outer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(18, 118, 225,0.08); }
.chat-input-outer.loading { opacity: 0.65; pointer-events: none; }
.chat-textarea { flex: 1; background: none; border: none; outline: none; font-size: 0.9rem; resize: none; max-height: 140px; font-family: inherit; line-height: 1.55; color: var(--gray-800); }
.chat-textarea::placeholder { color: var(--gray-400); }
.btn-send { width: 34px; height: 34px; border-radius: 8px; background: var(--primary); color: white; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.14s; }
.btn-send:hover:not(:disabled) { background: var(--primary-dark); transform: scale(1.05); }
.btn-send:disabled { background: var(--gray-200); cursor: not-allowed; transform: none; }
.btn-mic { width: 34px; height: 34px; border-radius: 8px; background: var(--gray-100); color: var(--gray-500); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.14s; }
.btn-mic:hover:not(:disabled) { background: var(--gray-200); color: var(--gray-700); }
.btn-mic:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-mic.listening { background: #fee2e2; color: #dc2626; animation: micPulse 1.4s infinite; }
.btn-mic.voice-active { background: #dbeafe; color: #2563eb; }
.btn-mic.voice-active.listening { background: #fee2e2; color: #dc2626; }
.chat-disclaimer { font-size: 0.7rem; color: var(--gray-400); text-align: center; margin-top: 0.5rem; transition: color 0.15s; }
.chat-disclaimer.listening-hint { color: #dc2626; font-weight: 600; }
@keyframes micPulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); }
    70% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}


/* End of Modals & Overlays section */

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.btn-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.15s;
}

.btn-close:hover { color: var(--gray-900); }

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

.modal-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--gray-50);
    border-bottom-left-radius: var(--bs-border-radius-xl);
    border-bottom-right-radius: var(--bs-border-radius-xl);
}


/* ════════════════════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════════════════════ */

.login-page { display: flex; min-height: 100vh; overflow: auto; }

.login-left {
    flex: 1;
    background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    padding: 3rem 4rem;
    position: relative;
    overflow: hidden;
}

.login-left::before {
    content: "";
    position: absolute;
    top: -20%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(18, 118, 225, 0.08) 0%, transparent 70%);
    z-index: 0;
}

.login-left-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: auto; }
.login-brand-icon { width: 44px; height: 44px; background: linear-gradient(135deg, var(--brand-600), var(--brand-800)); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; box-shadow: 0 4px 12px rgba(18, 118, 225,0.2); }
.login-brand-name { font-size: 1.1rem; font-weight: 700; color: var(--gray-900); }
.login-brand-sub { font-size: 0.68rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; margin-top: 0.1rem; }

.login-hero { margin: 3rem 0; }
.login-left h1 { font-size: 2.75rem; font-weight: 800; margin-bottom: 1.25rem; letter-spacing: -0.04em; line-height: 1.1; max-width: 480px; color: var(--gray-900); }
.login-left .login-hero p { font-size: 1.05rem; color: var(--gray-500); max-width: 420px; line-height: 1.6; margin: 0; }

.login-features-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
    max-width: 500px;
}

.login-feature { display: flex; align-items: center; gap: 0.875rem; font-size: 0.875rem; color: var(--gray-600); font-weight: 600; }
.login-feature-icon { width: 36px; height: 36px; background: white; border: 1.5px solid var(--gray-200); border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--brand-600); font-size: 1rem; transition: all 0.2s; }
.login-feature:hover .login-feature-icon { border-color: var(--brand-600); background: var(--brand-50); transform: translateY(-2px); }

.login-footer-left { margin-top: auto; font-size: 0.75rem; color: var(--gray-400); font-weight: 500; }

.login-right {
    width: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5rem;
    background: white;
    flex-shrink: 0;
}

.login-box {
    width: 100%;
    max-width: 360px;
}
.login-box h2 { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.4rem; color: var(--gray-900); letter-spacing: -0.025em; }
.login-box .login-sub { color: var(--gray-500); margin-bottom: 2rem; font-size: 0.9rem; }

.btn-login {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--bs-border-radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    box-shadow: 0 4px 6px -1px rgba(18, 118, 225,0.15), 0 2px 4px -2px rgba(18, 118, 225,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-login:hover {
    background: var(--primary-dark);
    box-shadow: 0 10px 15px -3px rgba(18, 118, 225,0.25), 0 4px 6px -4px rgba(18, 118, 225,0.15);
    transform: translateY(-2px);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* SSO Login Button */
.sso-login-section {
    margin-bottom: 1.5rem;
}

.btn-sso {
    width: 100%;
    padding: 0.875rem;
    background: white;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-300);
    border-radius: var(--bs-border-radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-sso:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.btn-sso:active {
    transform: translateY(0);
}

.btn-sso:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.sso-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    color: var(--gray-400);
    font-size: 0.875rem;
}

.sso-divider::before,
.sso-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-300);
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
    .sidebar-overlay.visible { display: block; }
    .main-content { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .lineage-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .page-body  { padding: 1rem; }
    .topbar     { padding: 0 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1.25rem; }
    .form-row   { grid-template-columns: 1fr; }
    .permissions-grid { grid-template-columns: 1fr; }
    .card-header { flex-direction: column; align-items: flex-start; padding: 0.875rem 1.25rem; }
    .filters-row { flex-wrap: wrap; width: 100%; }
    .search-input { min-width: unset; width: 100%; }
    .filter-select-dropdown { width: 100%; }
    .msg-bubble { max-width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid  { grid-template-columns: 1fr; }
    .login-left  { display: none; }
    .login-right { width: 100%; }
    .page-body   { padding: 0.875rem; }
}

/* ════════════════════════════════════════════════════════════
   STATUS & AUTH PAGES (Centered Layouts)
   ════════════════════════════════════════════════════════════ */

.centered-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background: linear-gradient(135deg, var(--gray-50) 0%, #e2e8f0 100%);
    position: relative;
    overflow-y: auto;
}

.status-card {
    background: #ffffff;
    padding: 3rem;
    border-radius: var(--bs-border-radius-2xl);
    box-shadow: var(--shadow-xl);
    max-width: 540px;
    width: 100%;
    text-align: center;
    animation: fadeIn 0.4s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
}

.status-icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 20px;
    margin-bottom: 2rem;
}

.status-icon-primary { background: var(--brand-50); color: var(--brand-600); }
.status-icon-danger  { background: var(--danger-light); color: var(--danger); }
.status-icon-warning { background: var(--warning-light); color: var(--warning); }
.status-icon-success { background: var(--success-light); color: var(--success); }

.status-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.status-message {
    font-size: 1rem;
    color: var(--gray-600);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.status-details {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 2rem;
    text-align: left;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
    color: var(--gray-700);
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

.status-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.status-footer {
    margin-top: 3rem;
    font-size: 0.82rem;
    color: var(--gray-400);
}

/* ════════════════════════════════════════════════════════════
   UTILITIES
   ════════════════════════════════════════════════════════════ */
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-column { display: flex; flex-direction: column; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--gray-500); }

/* ════════════════════════════════════════════════════════════
   PAGE: ASSETS
   ════════════════════════════════════════════════════════════ */

/* Locked (no-access) asset rows */
.asset-row-locked td { opacity: 0.6; }
.asset-row-locked { background: var(--gray-50); }
.locked-field { color: var(--gray-400); font-size: 0.85rem; }

/* Description preview hover effects */
.description-preview:hover {
    color: var(--blue-600) !important;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

/* Description popup styles */
.description-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.description-popup-content {
    background: white;
    border-radius: var(--bs-border-radius-xl);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: modal-in 0.2s ease-out;
}
.description-popup-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.description-popup-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
}
.description-popup-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-400);
    cursor: pointer;
    transition: color 0.15s;
}
.description-popup-close:hover { color: var(--gray-900); }
.description-popup-body {
    padding: 1.5rem;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--gray-700);
    white-space: pre-wrap;
    word-break: break-word;
}
.description-popup-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
    font-size: 0.75rem;
    color: var(--gray-400);
    border-bottom-left-radius: var(--bs-border-radius-xl);
    border-bottom-right-radius: var(--bs-border-radius-xl);
}

/* Request Access button */
.btn-request-access {
    background: #ffffff; 
    color: #c2410c; 
    border: 1.5px solid #fed7aa;
    font-size: 0.75rem; 
    padding: 0.2rem 0.6rem; 
    border-radius: 6px;
    cursor: pointer; 
    font-family: inherit; 
    white-space: nowrap;
    transition: all 0.15s;
}
.btn-request-access:hover { background: #fff7ed; transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Pending Requests badge button */
.btn-pending-requests {
    background: #ffffff; 
    color: #92400e; 
    border: 1.5px solid #fde68a;
    font-size: 0.72rem; 
    padding: 0.2rem 0.55rem; 
    border-radius: 6px;
    cursor: pointer; 
    font-family: inherit; 
    white-space: nowrap;
    transition: all 0.15s;
}
.btn-pending-requests:hover { background: #fef3c7; transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Assets card header layout */
.assets-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    flex-wrap: wrap;
}

@media (max-width: 1024px) {
    .assets-card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1.25rem;
    }

    .assets-header-title {
        width: 100%;
        flex-wrap: wrap;
    }

    .assets-filters-row {
        width: 100%;
        flex-direction: column;
    }

    .assets-search-input {
        width: 100% !important;
        min-width: unset;
    }

    .assets-filter-select {
        width: calc(50% - 0.25rem);
    }

    .assets-filter-select:nth-of-type(2n) {
        margin-right: 0;
    }

    #clearFiltersBtn {
        width: 100% !important;
    }

    .assets-header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .assets-header-actions .btn {
        flex: 1;
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    #domainFilterBar {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        overflow-x: auto;
        padding: 0.5rem 0;
        -webkit-overflow-scrolling: touch;
    }

    #domainFilterBar .filter-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .assets-card-header {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    .assets-filters-row {
        gap: 0.5rem;
        flex-direction: column;
    }

    .assets-filter-select {
        width: 100%;
    }

    .assets-header-actions {
        flex-direction: row;
        width: 100%;
        gap: 0.5rem;
    }

    .assets-header-actions .btn {
        flex: 1;
        min-width: 0;
        font-size: 0.75rem;
        padding: 0.5rem;
    }

    .table-wrapper {
        font-size: 0.8rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        border: 1px solid var(--gray-200);
    }

    .table {
        table-layout: fixed;
        width: 100%;
        font-size: 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.6rem 0.4rem;
    }

    .asset-actions-cell {
        min-width: 100px;
        padding: 0.65rem 0.4rem;
    }

    .asset-actions {
        flex-wrap: nowrap;
        gap: 0.2rem;
        justify-content: flex-end;
    }

    .asset-actions .btn {
        padding: 0.3rem 0.4rem;
        font-size: 0.7rem;
        min-height: 24px;
        flex-shrink: 0;
    }

    .asset-actions i {
        font-size: 0.65rem;
    }
}

/* ════════════════════════════════════════════════════════════
   PAGE: CHAT
   ════════════════════════════════════════════════════════════ */

.chat-layout {
    display: flex;
    height: calc(100vh - 104px);
    gap: 0;
    position: relative;
    background: var(--app-bg);
}

/* ── History Sidebar ── */
.chat-history-sidebar {
    width: 280px;
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
    border-radius: 12px 0 0 12px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    overflow: hidden;
    z-index: 100;
}

.chat-history-sidebar.collapsed {
    width: 0;
    opacity: 0;
    border-right: none;
}

.chat-history-header {
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
}

.chat-history-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    letter-spacing: -0.01em;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Recent / Shared tab switcher — only one of #chatHistoryList / #sharedWithMeList
   is visible at a time (see switchHistoryTab()), so both can freely use
   .chat-history-list's flex:1 without competing for space. */
.chat-history-tabs {
    display: flex;
    gap: 6px;
    padding: 8px 8px 0;
    background: #ffffff;
    border-bottom: 1px solid var(--gray-100);
}

.chat-history-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.5rem;
    margin-bottom: 8px;
    border: none;
    border-radius: 8px;
    background: var(--gray-100);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.15s;
}

.chat-history-tab:hover { color: var(--gray-700); background: var(--gray-200); }
.chat-history-tab.active { background: var(--brand-50); color: var(--primary); }

.chat-history-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.45rem;
    background: #ffffff;
    border: 1.5px solid var(--gray-200);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    gap: 12px;
}

.chat-history-item-content {
    flex: 1;
    min-width: 0;
}

.chat-history-delete {
    background: none;
    border: none;
    color: var(--gray-400);
    padding: 6px;
    border-radius: 6px;
    opacity: 0;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-history-item:hover .chat-history-delete {
    opacity: 1;
}

.chat-history-delete:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.chat-history-item.active .chat-history-delete {
    color: rgba(255, 255, 255, 0.6);
}

.chat-history-item.active .chat-history-delete:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.chat-history-item:hover {
    background: var(--brand-50);
    border-color: var(--brand-200);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(18, 118, 225, 0.08);
}

.chat-history-item.active {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(18, 118, 225, 0.2);
}

.chat-history-item-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item-meta {
    font-size: 0.72rem;
    color: var(--gray-500);
    display: flex;
    justify-content: space-between;
}

.chat-history-item.active .chat-history-item-meta {
    color: rgba(255,255,255,0.8);
}

.chat-history-footer {
    padding: 8px 14px;
    border-top: 1px solid var(--gray-200);
    background: white;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.chat-agents-sidebar {
    width: 280px;
    background: var(--gray-50);
    border-left: 1px solid var(--gray-200);
    border-radius: 0 12px 12px 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    overflow: hidden;
    z-index: 100;
}

.chat-agents-sidebar.collapsed {
    width: 0;
    opacity: 0;
    border-left: none;
}

.chat-sidebar-toggle {
    position: absolute;
    top: 20px;
    z-index: 101;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    color: var(--gray-600);
    font-size: 1rem;
}

#sidebarToggleBtn {
    right: 280px;
}

.chat-agents-sidebar.collapsed + #sidebarToggleBtn {
    right: 10px;
}

#historyToggleBtn {
    left: 280px;
}

.chat-history-sidebar.collapsed + #historyToggleBtn {
    left: 10px;
}

.chat-sidebar-toggle:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    color: var(--gray-900);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.chat-sidebar-toggle:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(18, 118, 225, 0.15), var(--shadow-sm);
}

.chat-sidebar-toggle:active {
    transform: translateY(0) scale(0.95);
    background: var(--gray-100);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    background: #ffffff;
}

/* ── Chat Messages ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    scroll-behavior: smooth;
    background: var(--app-bg);
}

@media (max-width: 1400px) { .chat-messages { padding: 1.25rem 1.25rem; } }
@media (max-width: 1024px) { .chat-messages { padding: 1rem 0.875rem; } }

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 10px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }

.chat-welcome {
    margin: auto;
    text-align: center;
    max-width: 440px;
    padding: 3rem 2rem;
    animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.welcome-icon { 
    font-size: 4rem; 
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.1));
}

.chat-welcome h3 { 
    font-size: 1.6rem; 
    font-weight: 800;
    color: var(--gray-900); 
    margin-bottom: 1rem; 
    letter-spacing: -0.02em;
}

.chat-welcome p { 
    color: var(--gray-500); 
    margin-bottom: 2rem; 
    font-size: 1rem;
    line-height: 1.6;
}

.welcome-badges { 
    display: flex; 
    gap: 0.75rem; 
    justify-content: center; 
    flex-wrap: wrap; 
}

.chat-agents-header {
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
}

.chat-agents-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    letter-spacing: -0.01em;
}

.chat-agents-header .btn-icon {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.chat-agents-header .btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.chat-agents-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-agent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.35rem;
    background: #ffffff;
    border: 1.5px solid var(--gray-200);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: inherit;
}

.chat-agent-item:hover {
    background: var(--brand-50);
    border-color: var(--brand-200);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(18, 118, 225, 0.08);
}

.chat-agent-item.active {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(18, 118, 225, 0.2);
}

.chat-agent-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.chat-agent-item.active .chat-agent-icon {
    background: var(--brand-100);
    color: var(--brand-600);
}

.chat-agent-info { flex: 1; min-width: 0; }

.chat-agent-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-agent-scope {
    font-size: 0.75rem;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-agents-loading {
    padding: 20px;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
}

.chat-agents-footer {
    padding: 8px 14px;
    border-top: 1px solid var(--gray-200);
    background: white;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0 12px; /* Space for toggle buttons if needed */
}

@media (max-width: 1024px) {
    .chat-agents-sidebar {
        position: absolute;
        left: 0; top: 0; bottom: 0;
        z-index: 100;
        box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    }
    .chat-agents-sidebar.collapsed { transform: translateX(-100%); }
    .chat-sidebar-toggle {
        left: 10px; top: 10px; z-index: 101;
        width: 40px; height: 40px; font-size: 1.2rem;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(4px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    .chat-agents-sidebar:not(.collapsed) + .chat-sidebar-toggle { left: 260px; }
    .chat-main { width: 100%; }
}

.src-drawer-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.35);
    z-index: 300; opacity: 0; pointer-events: none; transition: opacity 0.22s, display 0s 0.22s;
    display: none;
}
.src-drawer-overlay.open {
    display: block; opacity: 1; pointer-events: auto;
    transition: opacity 0.22s;
}
.src-drawer {
    position: fixed; right: 0; top: 0; bottom: 0; width: 480px; max-width: 92vw;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    z-index: 301; display: flex; flex-direction: column;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
    transform: translateX(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}
.src-drawer.open { transform: translateX(0); }
.src-drawer-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; padding: 20px 20px 16px; border-bottom: 1px solid var(--gray-100);
    flex-shrink: 0;
}
.src-drawer-close {
    background: none; border: none; cursor: pointer; font-size: 1rem;
    color: var(--gray-400); padding: 2px 6px; border-radius: 6px;
    flex-shrink: 0; transition: background 0.15s;
}
.src-drawer-close:hover { background: var(--gray-100); color: var(--gray-800); }
.src-drawer-relevance {
    padding: 14px 20px; border-bottom: 1px solid var(--gray-100); flex-shrink: 0;
}
.src-rel-bar {
    flex: 1; height: 6px; background: var(--gray-100); border-radius: 99px; overflow: hidden;
}
.src-rel-fill { height: 100%; background: var(--success); border-radius: 99px; transition: width 0.4s ease; }
.src-drawer-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.src-drawer-section { padding: 16px 20px; border-bottom: 1px solid var(--gray-100); }
.src-drawer-section:last-child { border-bottom: none; }
.src-drawer-section-label {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--gray-400); margin-bottom: 8px;
}
.src-drawer-snippet {
    margin: 0; font-size: 0.8rem; line-height: 1.7; color: var(--gray-700);
    white-space: pre-wrap; word-break: break-word;
    background: var(--gray-50); border: 1px solid var(--gray-100);
    border-radius: 8px; padding: 12px 14px; font-family: inherit;
    max-height: 360px; overflow-y: auto;
}
.src-drawer-footer {
    padding: 14px 20px; border-top: 1px solid var(--gray-100);
    display: flex; gap: 8px; flex-shrink: 0;
}
mark.src-hl {
    background: #fef08a; color: #713f12;
    border-radius: 2px; padding: 0 1px;
    font-style: inherit; font-weight: 600;
}
.src-filters {
    display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap;
}
.src-filter-select {
    font-size: 0.72rem; padding: 3px 24px 3px 8px; border-radius: 6px;
    border: 1px solid var(--gray-200); background: var(--gray-50);
    color: var(--gray-700); cursor: pointer; font-family: inherit;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 7px center;
    transition: border-color 0.15s;
}
.src-filter-select:focus { outline: none; border-color: var(--primary); }
.src-chips { display: flex; flex-direction: column; gap: 5px; }

.hash-picker-item {
    display: flex; align-items: center; gap: 8px; padding: 9px 14px;
    cursor: pointer; font-size: 0.84rem; border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
}
.hash-picker-item:last-child { border-bottom: none; }
.hash-picker-item.hp-active,
.hash-picker-item:hover { background: var(--brand-50); }
#agentHashPicker::before {
    content: "# Agents";
    display: block; padding: 6px 14px 4px; font-size: 0.7rem;
    font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
    color: #94a3b8; border-bottom: 1px solid #f1f5f9;
}

/* API Keys Specific */
.grid-keys-form { display: grid; grid-template-columns: 2fr 1fr auto; gap: 0.75rem; }
.new-key-alert { margin-top: 1rem; padding: 0.75rem; border: 1px solid #f59e0b; border-radius: 8px; background: #fffbeb; }

/* Runtime Settings Specific */
.search-input-settings { width: 320px; }
.settings-banner { 
    padding: 1rem 1.5rem; 
    border-bottom: 1px solid var(--gray-100); 
    background: #f8fafc; 
    font-size: 0.85rem; 
    color: var(--gray-600); 
    line-height: 1.5;
}
.col-w-260 { width: 260px; }
.col-w-90 { width: 90px; }
.text-mono { 
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace; 
    font-weight: 600;
}

.runtime-settings-table { table-layout: fixed; }
.runtime-settings-table th, .runtime-settings-table td { vertical-align: top; }
.setting-pre { 
    margin: 0; 
    max-width: 420px; 
    max-height: 140px; 
    overflow: auto; 
    white-space: pre-wrap; 
    word-break: break-word; 
    font-size: 0.78rem; 
    line-height: 1.5; 
    padding: 0.75rem; 
    background: #ffffff; 
    border: 1px solid var(--gray-200); 
    border-radius: 8px; 
    color: var(--gray-700);
}
.setting-pre-example { max-width: 340px; color: var(--gray-400); background: var(--gray-50); border-color: transparent; }
.setting-actions { display: flex; gap: 0.5rem; min-width: 160px; }
.setting-action-btn { flex: 1; justify-content: center; height: 32px; font-size: 0.75rem; }

/* Access Requests Specific */
.tab-bar { display: flex; gap: 0.5rem; border-bottom: 2px solid var(--gray-200); padding-bottom: 0; }
.tab-btn { background: none; border: none; padding: 0.5rem 1rem; cursor: pointer; font-weight: 500; color: var(--gray-500); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--gray-800); border-bottom-color: var(--gray-300); }

.select-status-mine { width: 140px; }
.select-status-all { width: 150px; }
.card-w-540 { max-width: 540px; }

.status-badge { display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; text-transform: capitalize; }
.status-pending  { background: #fef3c7; color: #92400e; }
.status-approved { background: #d1fae5; color: #065f46; }
.status-denied   { background: #fee2e2; color: #991b1b; }
.status-revoked  { background: #f1f5f9; color: #475569; }

/* Consolidation Utilities */
.modal-confirm-box { max-width: 420px; width: 92vw; }
.modal-input-box { max-width: 460px; width: 92vw; }
.modal-text { margin: 0; white-space: pre-line; color: var(--gray-600); font-size: 0.9rem; line-height: 1.6; }
.code-badge { background: var(--gray-100); padding: 2px 6px; border-radius: 4px; font-family: monospace; }

/* Connectors Specific */
.connector-icon-box { 
    width: 48px; 
    height: 48px; 
    border-radius: 12px; 
    background: linear-gradient(135deg, #f97316, #ea580c); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 1.5rem; 
    flex-shrink: 0; 
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
    color: white;
}
.notice-banner { 
    padding: 1rem 1.25rem; 
    border-bottom: 1px solid #fef3c7; 
    font-size: 0.875rem; 
    background: #fffbeb; 
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.col-w-170 { width: 170px; }
.col-w-140 { width: 140px; }
.col-w-180 { width: 180px; }
.col-w-110 { width: 110px; }
.col-w-80 { width: 80px; }
.col-w-60 { width: 60px; }
.modal-w-760 { width: min(760px, 96vw); }
.min-w-180 { min-width: 180px; }
.fs-sm { font-size: 0.85rem; }


/* ── Assets Page Consolidated (Part 2) ── */
.assets-header-title {
    display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0;
}
.assets-header-title h2 {
    margin: 0; font-size: 0.95rem; font-weight: 700;
    color: var(--gray-900); white-space: nowrap;
}
.assets-filters-row {
    display: flex; align-items: center; gap: 0.5rem;
    flex: 1; min-width: 0; flex-wrap: wrap;
}
.assets-search-input {
    height: 34px; padding: 0 0.75rem;
    border: 1.5px solid var(--gray-200); border-radius: 7px;
    font-size: 0.82rem; color: var(--gray-700);
    font-family: inherit; min-width: 180px; flex: 1;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.assets-search-input::placeholder { color: var(--gray-400); }
.assets-search-input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(18, 118, 225,0.1);
}
.assets-filter-select {
    height: 36px; padding: 0 32px 0 12px;
    border: 1.5px solid var(--gray-200); border-radius: 10px;
    font-size: 0.85rem; color: var(--gray-700);
    font-family: inherit; cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    transition: all 0.2s;
    background-size: 10px 6px;
}
.assets-filter-select:focus {
    outline: none; border-color: var(--brand-600);
    box-shadow: 0 0 0 4px rgba(18, 118, 225, 0.1);
}
.assets-filter-select:hover { border-color: var(--brand-300); }
.assets-header-actions {
    display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0;
}
.assets-header-actions .btn { height: 34px; }

/* Domain filter count badge */
.domain-count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 18px; padding: 0 5px;
    background: rgba(0,0,0,0.12); color: inherit;
    border-radius: 20px; font-size: 0.7rem; font-weight: 700;
    margin-left: 4px; line-height: 1;
}
.filter-btn.active .domain-count-badge {
    background: rgba(255,255,255,0.3); color: #fff;
}

/* Asset row highlight (from drawer "View in Catalog" link) */
@keyframes asset-highlight-pulse {
    0%   { background: #ede9fe; }
    60%  { background: #ede9fe; }
    100% { background: transparent; }
}
.asset-row-highlight { animation: asset-highlight-pulse 3s ease forwards; }

/* Asset row hover effect */
.asset-row {
    transition: background 0.15s, transform 0.1s;
}

.asset-row:hover {
    background: var(--brand-50) !important;
}

.embed-status-btn {
    cursor: pointer;
    border: none;
    font: inherit;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 6px;
    font-weight: 700;
}
.embed-status-btn:hover { opacity: 0.9; transform: translateY(-1px) scale(1.05); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* Keep row action buttons aligned and responsive on all viewport widths */
.asset-actions-cell {
    min-width: 260px;
}

.asset-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.asset-actions .btn {
    white-space: nowrap;
    min-height: 30px;
    justify-content: center;
}

.asset-actions .icon-only-btn {
    width: 34px;
    min-width: 34px;
    padding-left: 0;
    padding-right: 0;
    font-size: 0.9rem;
}

@media (max-width: 1200px) {
    .asset-actions-cell { min-width: 240px; }
}

@media (max-width: 768px) {
    .asset-actions-cell { min-width: 220px; }
    .asset-actions { gap: 0.3rem; }
}

.chunk-job-bar {
    align-items: center;
    flex-wrap: wrap;
}

/* Source Picker Custom Component */
.source-picker-btn {
    width: 100%;
    height: 38px;
    padding: 0 1rem;
    background: white;
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    text-align: left;
    font-size: 0.9rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.source-picker-btn:hover { border-color: var(--brand-300); background: var(--gray-50); }
.source-picker-btn:focus { outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 4px rgba(18, 118, 225, 0.1); }

.source-picker-panel {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-top: 6px;
    overflow: hidden;
    z-index: 100;
}

.source-picker-option {
    padding: 0.75rem 1rem;
    transition: background 0.15s;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    display: block;
}

.source-picker-option:hover { background: var(--brand-50); }
.source-picker-option.is-disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); }

/* ── Asset Description Popup (JS-Injected) ── */
.description-popup-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.description-popup-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
    position: relative;
}

.description-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.description-popup-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.description-popup-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.description-popup-close:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.description-popup-body {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--gray-700);
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    max-height: 50vh;
    overflow-y: auto;
}

.description-popup-footer {
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--gray-400);
    text-align: right;
}

.overflow-hidden { overflow: hidden !important; }

/* ============================================================
   STATS DASHBOARD - PAGE SPECIFIC STYLES
   ============================================================ */
:root {
    --brand-color: #0066ff;
    --brand-rgb: 0, 102, 255;
}

.stats-container {
    padding: 1.5rem 0;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2.5rem;
}

.header-info p {
    margin: 0;
    font-size: 0.9rem;
}

.header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.card-action {
    display: flex;
    gap: 0.75rem;
}

.stats-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, var(--gray-900), var(--brand-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.last-updated {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
    text-align: right;
}

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

.stat-card {
    position: relative;
    padding: 2rem;
    border-radius: 20px;
    background: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.1);
}

.stat-card.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
}

.card-icon {
    font-size: 1.5rem;
    color: var(--brand-color);
    margin-bottom: 1.25rem;
    width: 45px;
    height: 45px;
    background: rgba(var(--brand-rgb), 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.stat-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.main-stat {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

.stat-details {
    border-top: 1px solid var(--gray-100);
    padding-top: 1rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.detail-item span:first-child {
    color: var(--gray-500);
}

.detail-item span:last-child {
    font-weight: 600;
    color: var(--gray-800);
}

.status-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    background: var(--gray-100);
}

.status-ok { color: #16a34a !important; background: #f0fdf4; }
.status-error { color: #dc2626 !important; background: #fef2f2; }
.status-warning { color: #d97706 !important; background: #fffbeb; }

.card-status-pulse {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gray-300);
}

.card-status-pulse.status-ok {
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: pulse-green 2s infinite;
}

.card-status-pulse.status-error {
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.bottleneck-section {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid var(--gray-200);
}

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

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--gray-800);
}

.bottleneck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.bottleneck-item {
    padding: 1.25rem;
    background: var(--gray-50);
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.bottleneck-item:hover {
    background: white;
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.bottleneck-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.bottleneck-item .label {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.loading-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--gray-400);
    font-style: italic;
}

.refresh-btn i {
    transition: transform 0.5s ease;
}


.modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
}

.modal-body {
    padding: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.policy-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.policy-item {
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.policy-item:hover {
    background: white;
    transform: translateX(5px);
    border-color: var(--brand-color);
}

.policy-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(var(--brand-rgb), 0.1);
    color: var(--brand-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.policy-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-800);
}

.btn-detail {
    background: rgba(var(--brand-rgb), 0.1);
    color: var(--brand-color);
    border: 1px solid rgba(var(--brand-rgb), 0.2);
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    width: 100%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.btn-detail:hover {
    background: var(--brand-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--brand-rgb), 0.3);
}

.btn-detail:active {
    transform: translateY(0);
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.animate-scale-in {
    animation: scaleIn 0.3s ease forwards;
}

.refresh-btn:active i {
    transform: rotate(360deg);
}

/* ═══════════════════════════════════════════════════════════════════
   GLOBAL DOMAINS & ASSETS POPUPS
   ═══════════════════════════════════════════════════════════════════ */

.gp-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10050;
    backdrop-filter: blur(2px);
}

.gp-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 94vw;
    max-height: 82vh;
    background: var(--card-bg, #fff);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.22);
    z-index: 10051;
    overflow: hidden;
    flex-direction: column;
}

.gp-popup--domains { width: 500px; }
.gp-popup--assets  { width: 580px; }
.gp-popup--users    { width: 500px; }

.gp-popup.is-open { display: flex; }

.gp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
}

.gp-header__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-800, #1f2937);
}

.gp-header__title i { color: var(--primary, #4f46e5); }

.gp-header__subtitle {
    color: var(--gray-400, #9ca3af);
    font-size: 0.75rem;
    margin-top: 2px;
    display: block;
}

.gp-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--gray-400, #9ca3af);
    line-height: 1;
    padding: 4px;
    transition: color 0.15s;
}
.gp-close-btn:hover { color: var(--gray-700, #374151); }

.gp-search-bar {
    padding: 8px 14px;
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

.gp-search-bar--row {
    display: flex;
    gap: 8px;
}

.gp-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    font-size: 0.84rem;
    outline: none;
    background: var(--input-bg, #fff);
    transition: border-color 0.15s;
}
.gp-search-input:focus { border-color: var(--primary, #4f46e5); }

.gp-search-input--flex { flex: 1; width: auto; }

.gp-domain-filter {
    padding: 8px 10px;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    font-size: 0.84rem;
    outline: none;
    background: var(--input-bg, #fff);
}

.gp-list {
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

#usersPopupList {
    scrollbar-width: thin;
}
#usersPopupList::-webkit-scrollbar { width: 6px; }
#usersPopupList::-webkit-scrollbar-track { background: transparent; }
#usersPopupList::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 10px; }
#usersPopupList::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }

.gp-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-100, #f3f4f6);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gp-footer__count {
    color: var(--gray-400, #9ca3af);
    font-size: 0.78rem;
}

/* ── Popup list items (rendered via JS) ── */

.gp-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-100, #f3f4f6);
}

.gp-item__icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.gp-item__icon--sm {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
}

.gp-item__body {
    flex: 1;
    min-width: 0;
}

.gp-item__row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.gp-item__name {
    font-weight: 600;
    font-size: 0.87rem;
    color: var(--gray-800, #1f2937);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.gp-item__desc {
    font-size: 0.76rem;
    color: var(--gray-400, #9ca3af);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gp-badge {
    font-size: 0.68rem;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.gp-badge--cls {
    font-size: 0.67rem;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
    flex-shrink: 0;
}

.gp-item__type {
    font-size: 0.72rem;
    color: var(--gray-400, #9ca3af);
    flex-shrink: 0;
}

.gp-empty {
    text-align: center;
    padding: 2rem;
    color: var(--gray-400, #9ca3af);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.gp-empty i { font-size: 2rem; opacity: 0.3; }

/* ── Chat sidebar scope buttons ── */
.chat-agents-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
}

.chat-agents-scope-btns {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.chat-scope-btn {
    flex: 1;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
