        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        :root {
            /* ===== Aequalis / 3PS house style (default light theme) =====
               Warm cream canvas, deep-navy surfaces, periwinkle accent, serif
               headings — matched to the Payer Intelligence portal screenshots. */
            --brand-navy: #212a4a;          /* sidebar, hero banners, table headers, primary buttons */
            --brand-navy-2: #1a2240;        /* deeper navy for gradient end */
            --brand-gradient: linear-gradient(135deg, #232d50 0%, #1a2240 100%);
            --accent: #8b93d4;              /* periwinkle highlight */
            --accent-ink: #5b6aa0;          /* slate-blue links / eyebrows */
            --accent-soft: rgba(139, 147, 212, 0.14);
            --pos: #2f9e74;                 /* positive deltas */
            --neg: #c0392b;                 /* negative deltas */

            /* Surfaces */
            --bg-gradient-start: #f4f3ee;   /* flat cream canvas (no purple gradient) */
            --bg-gradient-end: #efece4;
            --container-bg: #f4f3ee;
            --text-color: #28304c;          /* ink on cream */
            --text-secondary: #5b6479;
            --border-color: #e6e0d4;        /* warm hairline */
            --card-bg: #ffffff;
            --input-bg: #ffffff;
            --input-border: #ddd6c8;
            --tab-bg: #ffffff;
            --hover-bg: rgba(33, 42, 74, 0.05);
            --shadow-color: rgba(33,42,74,0.08);
            --shadow-color-strong: rgba(33,42,74,0.14);

            /* 3PS web typography */
            --font-heading: 'Libre Baskerville', Georgia, serif;
            --font-body: 'Work Sans', 'Segoe UI', 'Helvetica Neue', sans-serif;
        }
        
        body.dark-mode {
            /* ===== Dark mode — navy family, consistent with the house style =====
               Deep blue-navy canvas with raised navy surfaces, brighter
               periwinkle accent for contrast on dark. */
            --brand-navy: #2b366b;          /* raised navy (sidebar/buttons read slightly lifted on dark) */
            --brand-navy-2: #1d2547;
            --brand-gradient: linear-gradient(135deg, #2b366b 0%, #1d2547 100%);
            --accent: #aab2ee;              /* brighter periwinkle for dark bg */
            --accent-ink: #aab2ee;          /* links/eyebrows readable on dark */
            --accent-soft: rgba(139, 147, 212, 0.20);
            --pos: #4ecb97;
            --neg: #f1746a;

            /* Surfaces */
            --bg-gradient-start: #0c1024;
            --bg-gradient-end: #0a0e20;
            --container-bg: #0b0f22;        /* deep navy canvas */
            --text-color: #e8eaf4;
            --text-secondary: #a3abce;
            --border-color: rgba(255,255,255,0.10);
            --card-bg: #141a36;             /* raised navy card */
            --input-bg: #11162e;
            --input-border: rgba(255,255,255,0.14);
            --tab-bg: #11162e;
            --hover-bg: rgba(139, 147, 212, 0.14);
            --shadow-color: rgba(0,0,0,0.45);
            --shadow-color-strong: rgba(0,0,0,0.7);
        }
        
        body {
            font-family: var(--font-body);
            background: var(--container-bg);
            min-height: 100vh;
            padding: 0;
            color: var(--text-color);
            transition: background 0.3s ease, color 0.3s ease;
        }

        h1, h2, h3, h4, h5, h6 {
            font-family: var(--font-heading);
        }

        /* Lucide icons render as inline SVGs; size them relative to text */
        svg.lucide {
            width: 1em;
            height: 1em;
            vertical-align: -0.125em;
            stroke-width: 2;
            flex-shrink: 0;
        }
        .nav-icon svg.lucide,
        .tab svg.lucide {
            width: 1.1em;
            height: 1.1em;
        }
        /* Larger icons in section hero headers */
        h2 svg.lucide,
        .hero-icon svg.lucide {
            width: 1em;
            height: 1em;
            vertical-align: -0.1em;
            margin-right: 6px;
        }
        
        .container {
            max-width: none;
            margin: 0;
            background: var(--container-bg);
            border-radius: 0;
            box-shadow: none;
            overflow: hidden;
            transition: background 0.3s ease, box-shadow 0.3s ease;
        }
        
        header {
            background: var(--brand-gradient);
            color: white;
            padding: 30px;
            text-align: center;
            position: relative;
        }
        
        header h1 {
            font-size: 2.5em;
            margin-bottom: 10px;
        }
        
        header p {
            font-size: 1.1em;
            opacity: 0.9;
        }
        
        .dark-mode-toggle {
            background: rgba(255, 255, 255, 0.2);
            border: 2px solid rgba(255, 255, 255, 0.3);
            color: white;
            padding: 10px 20px;
            border-radius: 25px;
            cursor: pointer;
            font-size: 1.1em;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
            backdrop-filter: blur(10px);
        }
        
        .dark-mode-toggle:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.05);
        }
        
        /* ==================== Authentication Styles ==================== */
        
        .header-actions {
            position: absolute;
            top: 20px;
            right: 30px;
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .user-menu {
            position: relative;
            display: flex;
            align-items: center;
        }
        
        .user-button {
            background: rgba(255, 255, 255, 0.2);
            border: 2px solid rgba(255, 255, 255, 0.3);
            color: white;
            padding: 8px 16px;
            border-radius: 25px;
            cursor: pointer;
            font-size: 1em;
            display: flex;
            align-items: center;
            gap: 8px;
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
        }
        
        .user-button:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.02);
        }
        
        .user-avatar {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 0.9em;
        }
        
        .user-dropdown {
            position: absolute;
            top: 100%;
            right: 0;
            margin-top: 10px;
            background: var(--card-bg);
            border-radius: 12px;
            box-shadow: 0 10px 40px var(--shadow-color-strong);
            min-width: 220px;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.2s ease;
            z-index: 1000;
            border: 1px solid var(--border-color);
        }
        
        .user-dropdown.active {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }
        
        .user-dropdown-header {
            padding: 15px;
            border-bottom: 1px solid var(--border-color);
            text-align: center;
        }
        
        .user-dropdown-header .user-name {
            font-weight: 600;
            color: var(--text-color);
            font-size: 1.1em;
        }
        
        .user-dropdown-header .user-role {
            font-size: 0.85em;
            color: var(--text-secondary);
            text-transform: capitalize;
            margin-top: 2px;
        }
        
        .user-dropdown-item {
            padding: 12px 15px;
            display: flex;
            align-items: center;
            gap: 10px;
            cursor: pointer;
            transition: background 0.2s ease;
            color: var(--text-color);
            text-decoration: none;
        }
        
        .user-dropdown-item:hover {
            background: var(--hover-bg);
        }
        
        .user-dropdown-item.danger {
            color: #ef4444;
        }
        
        .user-dropdown-divider {
            height: 1px;
            background: var(--border-color);
            margin: 5px 0;
        }
        
        /* Login/Register Modal */
        .auth-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            backdrop-filter: blur(5px);
            z-index: 10000;
            align-items: center;
            justify-content: center;
        }
        
        .auth-modal.active {
            display: flex;
        }
        
        .auth-modal-content {
            background: var(--card-bg);
            border-radius: 16px;
            width: 100%;
            max-width: 420px;
            max-height: 90vh;
            display: flex;
            flex-direction: column;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
            overflow: hidden;
            animation: modalSlideIn 0.3s ease;
        }
        
        @keyframes modalSlideIn {
            from {
                opacity: 0;
                transform: translateY(-30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .auth-modal-header {
            background: var(--brand-gradient);
            color: white;
            padding: 25px;
            text-align: center;
            position: relative;
            flex-shrink: 0;
        }
        
        .auth-modal-header h2 {
            margin: 0;
            font-size: 1.5em;
        }
        
        .auth-modal-header p {
            margin: 5px 0 0;
            opacity: 0.9;
            font-size: 0.95em;
        }
        
        .auth-modal-close {
            position: absolute;
            top: 15px;
            right: 15px;
            background: rgba(255, 255, 255, 0.2);
            border: none;
            color: white;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            cursor: pointer;
            font-size: 1.2em;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s ease;
        }
        
        .auth-modal-close:hover {
            background: rgba(255, 255, 255, 0.3);
        }
        
        .auth-modal-body {
            padding: 25px;
            overflow-y: auto;
            flex: 1 1 auto;
            min-height: 0;
        }
        
        .auth-tabs {
            display: flex;
            margin-bottom: 20px;
            border-radius: 10px;
            background: var(--tab-bg);
            padding: 4px;
        }
        
        .auth-tab {
            flex: 1;
            padding: 12px;
            border: none;
            background: transparent;
            cursor: pointer;
            font-size: 1em;
            font-weight: 500;
            color: var(--text-secondary);
            border-radius: 8px;
            transition: all 0.2s ease;
        }
        
        .auth-tab.active {
            background: var(--card-bg);
            color: var(--accent-ink);
            box-shadow: 0 2px 8px var(--shadow-color);
        }
        
        .auth-form {
            display: none;
        }
        
        .auth-form.active {
            display: block;
        }
        
        .auth-input-group {
            margin-bottom: 15px;
        }
        
        .auth-input-group label {
            display: block;
            margin-bottom: 6px;
            font-weight: 500;
            color: var(--text-color);
            font-size: 0.9em;
        }
        
        .auth-input-group input {
            width: 100%;
            padding: 12px 15px;
            border: 2px solid var(--input-border);
            border-radius: 10px;
            font-size: 1em;
            background: var(--input-bg);
            color: var(--text-color);
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }
        
        .auth-input-group input:focus {
            outline: none;
            border-color: var(--accent-ink);
            box-shadow: 0 0 0 3px rgba(139, 147, 212, 0.1);
        }
        
        .auth-input-group input.error {
            border-color: #ef4444;
        }
        
        .auth-error {
            color: #ef4444;
            font-size: 0.85em;
            margin-top: 5px;
            display: none;
        }
        
        .auth-error.visible {
            display: block;
        }
        
        .auth-submit {
            width: 100%;
            padding: 14px;
            background: var(--brand-gradient);
            color: white;
            border: none;
            border-radius: 10px;
            font-size: 1.1em;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            margin-top: 10px;
        }
        
        .auth-submit:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(139, 147, 212, 0.4);
        }
        
        .auth-submit:disabled {
            opacity: 0.7;
            cursor: not-allowed;
            transform: none;
        }
        
        .auth-link {
            text-align: center;
            margin-top: 15px;
            font-size: 0.9em;
            color: var(--text-secondary);
        }
        
        .auth-link a {
            color: var(--accent-ink);
            text-decoration: none;
            font-weight: 500;
        }
        
        .auth-link a:hover {
            text-decoration: underline;
        }
        
        .auth-message {
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 15px;
            font-size: 0.9em;
            display: none;
        }
        
        .auth-message.success {
            display: block;
            background: rgba(34, 197, 94, 0.1);
            color: #16a34a;
            border: 1px solid rgba(34, 197, 94, 0.3);
        }
        
        .auth-message.error {
            display: block;
            background: rgba(239, 68, 68, 0.1);
            color: #ef4444;
            border: 1px solid rgba(239, 68, 68, 0.3);
        }
        
        /* Permission-based tab visibility */
        .tab[data-permission].hidden {
            display: none !important;
        }
        
        /* Role badges */
        .role-badge {
            display: inline-block;
            padding: 3px 10px;
            border-radius: 12px;
            font-size: 0.75em;
            font-weight: 600;
            text-transform: uppercase;
        }
        
        .role-badge.admin {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
        }
        
        .role-badge.moderator {
            background: var(--brand-gradient);
            color: white;
        }
        
        .role-badge.user {
            background: var(--tab-bg);
            color: var(--text-secondary);
        }
        
        /* Login Required Screen — split panel (navy brand left / cream form right) */
        .login-required-screen {
            display: grid;
            grid-template-columns: 1fr 1fr;
            min-height: 100vh;
        }
        .login-required-screen.hidden {
            display: none;
        }

        /* Left: navy brand panel */
        .login-brand-panel {
            background: var(--brand-gradient);
            color: #fff;
            padding: 64px 60px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }
        .login-brand-logo {
            display: flex;
            align-items: center;
            gap: 12px;
            font-family: var(--font-body);
            font-weight: 700;
            letter-spacing: 0.04em;
            font-size: 1.25em;
        }
        .login-brand-logo .mark {
            width: 38px; height: 38px; border-radius: 9px;
            background: rgba(255,255,255,0.14);
            display: flex; align-items: center; justify-content: center;
        }
        .login-brand-logo .mark::before {
            content: ""; width: 18px; height: 3px; border-radius: 2px;
            background: #fff; box-shadow: 0 6px 0 rgba(255,255,255,0.85);
        }
        .login-brand-copy { max-width: 460px; }
        .login-brand-copy h1 {
            font-family: var(--font-heading);
            font-size: 2.7em;
            line-height: 1.15;
            font-weight: 700;
            margin-bottom: 20px;
            color: #fff;
        }
        .login-brand-copy p {
            font-size: 1.05em;
            line-height: 1.6;
            color: rgba(255,255,255,0.72);
        }
        .login-brand-foot {
            font-size: 0.85em;
            color: rgba(255,255,255,0.45);
            letter-spacing: 0.02em;
        }

        /* Right: cream sign-in form */
        .login-form-panel {
            background: var(--container-bg);
            padding: 64px 60px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: flex-start;
        }
        .login-form-inner { width: 100%; max-width: 380px; margin: 0 auto; }
        .login-form-inner h2 {
            font-family: var(--font-heading);
            font-size: 1.7em;
            color: var(--text-color);
            margin-bottom: 6px;
        }
        .login-form-inner .login-sub {
            font-size: 0.98em;
            color: var(--text-secondary);
            margin-bottom: 30px;
        }
        .login-field { margin-bottom: 18px; }
        .login-field label {
            display: block;
            font-size: 0.82em;
            font-weight: 600;
            color: var(--text-color);
            margin-bottom: 7px;
        }
        .login-field input {
            width: 100%;
            padding: 13px 15px;
            font-size: 1em;
            font-family: var(--font-body);
            background: var(--input-bg);
            border: 1px solid var(--input-border);
            border-radius: 8px;
            color: var(--text-color);
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }
        .login-field input:focus {
            outline: none;
            border-color: var(--accent-ink);
            box-shadow: 0 0 0 3px var(--accent-soft);
        }
        .login-submit-btn {
            width: 100%;
            padding: 14px;
            font-size: 1.02em;
            font-weight: 600;
            font-family: var(--font-body);
            background: var(--brand-navy);
            color: #fff;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            margin-top: 6px;
            transition: filter 0.2s ease, transform 0.15s ease;
        }
        .login-submit-btn:hover { filter: brightness(1.12); }
        .login-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }
        .login-form-error {
            color: var(--neg);
            font-size: 0.9em;
            margin-bottom: 14px;
            min-height: 1.1em;
        }
        .login-form-note {
            font-size: 0.85em;
            color: var(--text-secondary);
            margin-top: 22px;
            line-height: 1.5;
        }
        .login-form-note a { color: var(--accent-ink); font-weight: 600; cursor: pointer; }

        @media (max-width: 860px) {
            .login-required-screen { grid-template-columns: 1fr; }
            .login-brand-panel { padding: 48px 32px; gap: 40px; }
            .login-brand-copy h1 { font-size: 2.1em; }
            .login-form-panel { padding: 48px 32px; }
        }
        
        /* Main content - hidden when not logged in.
           Two-column layout: left nav sidebar + content (mirrors admin panel). */
        .main-content {
            display: grid;
            grid-template-columns: 230px 1fr;
            align-items: stretch;
            min-height: 100vh;
        }
        
        .main-content.hidden {
            display: none;
        }
        
        /* ==================== End Authentication Styles ==================== */
        
        .search-section {
            padding: 30px;
            background: var(--container-bg);
            transition: background 0.3s ease;
        }
        
        .search-box {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }
        
        .search-box input,
        .search-box select {
            padding: 12px 20px;
            border: 2px solid var(--input-border);
            border-radius: 8px;
            font-size: 1em;
            flex: 1;
            background: var(--input-bg);
            color: var(--text-color);
            transition: border-color 0.3s, background 0.3s, color 0.3s;
        }
        
        .search-box input:focus,
        .search-box select:focus {
            outline: none;
            border-color: var(--accent-ink);
        }
        
        .search-box button {
            padding: 12px 30px;
            background: var(--brand-gradient);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 1em;
            cursor: pointer;
            transition: transform 0.2s;
            font-weight: 600;
        }
        
        .search-box button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(139, 147, 212, 0.4);
        }
        
        /* Main navigation — left sidebar (styled to match the admin panel) */
        .tabs {
            grid-column: 1;
            grid-row: 1 / -1;
            display: flex;
            flex-direction: column;
            gap: 0;
            padding: 10px 0;
            background: #283147;
            border-bottom: none;
            align-self: stretch;
            overflow-y: auto;
            transition: background 0.3s ease;
        }

        .nav-sidebar-header {
            padding: 16px 20px 14px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            margin-bottom: 6px;
        }

        .nav-sidebar-header h3 {
            margin: 0;
            font-size: 1.05em;
            font-weight: 700;
            color: #fff;
        }

        .nav-sidebar-header p {
            margin: 4px 0 0;
            font-size: 0.8em;
            color: rgba(255, 255, 255, 0.55);
        }

        /* User menu in the sidebar (replaces the old top-right menu) */
        .nav-user-menu {
            padding: 14px 14px 8px;
        }

        .nav-user-button {
            display: flex;
            align-items: center;
            gap: 10px;
            width: 100%;
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.12);
            color: #fff;
            padding: 10px 12px;
            border-radius: 10px;
            cursor: pointer;
            font-family: inherit;
            transition: background 0.2s ease, border-color 0.2s ease;
        }

        .nav-user-button:hover {
            background: rgba(255, 255, 255, 0.12);
        }

        .nav-user-button.active {
            background: rgba(173, 132, 198, 0.22);
            border-color: rgba(173, 132, 198, 0.5);
        }

        .nav-user-meta {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            flex: 1;
            min-width: 0;
        }

        .nav-user-name {
            font-weight: 600;
            font-size: 0.95em;
            line-height: 1.2;
            max-width: 130px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .nav-user-role {
            font-size: 0.72em;
            color: rgba(255, 255, 255, 0.55);
            text-transform: capitalize;
        }

        .nav-user-caret {
            font-size: 1.1em;
            color: rgba(255, 255, 255, 0.5);
            flex-shrink: 0;
        }

        /* Payer selector pill in the sidebar */
        .nav-payer-selector {
            display: flex;
            align-items: center;
            gap: 10px;
            width: calc(100% - 28px);
            margin: 0 14px 10px;
            padding: 10px 12px;
            border-radius: 8px;
            background: rgba(173, 132, 198, 0.15);
            border: 1px solid rgba(173, 132, 198, 0.3);
            color: #fff;
            cursor: pointer;
            font-size: 0.85em;
            font-family: inherit;
            transition: background 0.2s ease;
        }

        .nav-payer-selector:hover {
            background: rgba(173, 132, 198, 0.28);
        }

        .nav-payer-selector .nav-payer-text {
            flex: 1;
            text-align: left;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .nav-payer-selector .nav-payer-caret {
            font-size: 0.7em;
            opacity: 0.6;
            flex-shrink: 0;
        }

        /* Divider between the account/payer block and the navigation tabs */
        .nav-divider {
            height: 1px;
            background: rgba(255, 255, 255, 0.1);
            margin: 4px 14px 8px;
        }

        /* User profile page (opened from the sidebar account button) */
        .profile-avatar-lg {
            width: 64px;
            height: 64px;
            border-radius: 50%;
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 1.8em;
            color: #fff;
            flex-shrink: 0;
        }

        .profile-detail-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 16px;
            padding: 11px 0;
            border-bottom: 1px solid var(--border-color);
        }

        .profile-detail-label {
            color: var(--text-secondary);
            font-size: 0.9em;
        }

        .profile-detail-value {
            color: var(--text-color);
            font-weight: 600;
            text-align: right;
            word-break: break-word;
        }

        .profile-action-btn {
            display: flex;
            align-items: center;
            gap: 12px;
            width: 100%;
            padding: 13px 14px;
            margin-bottom: 8px;
            background: var(--hover-bg);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            color: var(--text-color);
            cursor: pointer;
            font-size: 0.95em;
            font-family: inherit;
            text-align: left;
            transition: background 0.2s ease, transform 0.1s ease;
        }

        .profile-action-btn:hover {
            background: var(--border-color);
            transform: translateX(2px);
        }

        .profile-action-btn.danger {
            color: #ef4444;
        }

        /* AI MCP Bridge wizard — client picker cards */
        .mcp-client-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
        }

        .mcp-client-card {
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 18px 12px;
            background: var(--card-bg, #f8f9fa);
            border: 2px solid var(--border-color, #ddd);
            border-radius: 10px;
            color: var(--text-color, #333);
            cursor: pointer;
            font-family: inherit;
            font-size: 0.92em;
            font-weight: 600;
            transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
        }

        .mcp-client-card:hover {
            border-color: var(--accent-ink);
            transform: translateY(-1px);
        }

        .mcp-client-card.selected {
            border-color: var(--accent-ink);
            background: rgba(139, 147, 212, 0.10);
        }

        .mcp-client-card svg {
            width: 26px;
            height: 26px;
            color: var(--accent-ink);
        }

        .mcp-client-badge {
            position: absolute;
            top: 6px;
            right: 6px;
            font-size: 0.62em;
            font-weight: 700;
            padding: 2px 7px;
            border-radius: 10px;
            background: var(--accent-ink);
            color: #fff;
        }

        .tab {
            display: flex;
            align-items: center;
            gap: 12px;
            width: 100%;
            padding: 13px 20px;
            cursor: pointer;
            border: none;
            background: transparent;
            font-size: 0.95em;
            font-weight: 500;
            color: rgba(255, 255, 255, 0.7);
            text-align: left;
            line-height: 1.3;
            transition: all 0.2s ease;
            border-left: 3px solid transparent;
        }

        .tab.dragging {
            opacity: 0.35;
        }

        .tab.drag-over-top {
            box-shadow: inset 0 3px 0 0 #ad84c6;
        }

        .tab.drag-over-bottom {
            box-shadow: inset 0 -3px 0 0 #ad84c6;
        }
        
        .tab:hover {
            color: #fff;
            background: rgba(255, 255, 255, 0.07);
        }
        
        .tab.active {
            color: #fff;
            background: rgba(173, 132, 198, 0.18);
            border-left-color: #ad84c6;
            font-weight: 600;
        }
        
        .tab-content {
            display: none;
            grid-column: 2;
            min-width: 0;
        }
        
        .tab-content.active {
            display: block;
        }

        /* Collapse the nav sidebar into a horizontal bar on narrow screens */
        @media (max-width: 900px) {
            .main-content {
                grid-template-columns: 1fr;
            }

            .tabs {
                grid-row: auto;
                position: static;
                flex-direction: row;
                flex-wrap: wrap;
                max-height: none;
                gap: 4px;
                padding: 8px 12px;
            }

            .nav-sidebar-header {
                display: none;
            }

            .nav-user-menu {
                flex: 1 1 100%;
                padding: 8px 0;
                margin-bottom: 4px;
            }

            .nav-payer-selector {
                flex: 1 1 100%;
                width: 100%;
                margin: 0 0 8px;
            }

            .tab {
                width: auto;
                border-left: none;
                border-bottom: 3px solid transparent;
                border-radius: 6px;
                padding: 8px 14px;
                font-size: 0.85em;
            }

            .tab.active {
                border-left-color: transparent;
                border-bottom-color: #ad84c6;
            }

            .tab-content {
                grid-column: 1;
            }
        }
        
        .field-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 15px;
            margin: 15px 0;
        }
        
        .field-item {
            background: var(--tab-bg);
            padding: 12px;
            border-radius: 6px;
            border-left: 3px solid var(--accent-ink);
        }
        
        .field-label {
            font-size: 0.85em;
            color: var(--text-secondary);
            font-weight: 600;
            margin-bottom: 5px;
        }
        
        .field-value {
            color: var(--text-color);
            font-size: 1em;
        }
        
        .field-value.highlight {
            color: var(--accent-ink);
            font-weight: 600;
            font-size: 1.2em;
        }
        
        .provider-card {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 15px;
            margin: 10px 0;
            transition: background 0.3s ease, border-color 0.3s ease;
        }
        
        .price-card {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 15px;
            margin: 10px 0;
            transition: background 0.3s ease, border-color 0.3s ease;
        }
        
        .section-header {
            font-size: 1.1em;
            font-weight: 600;
            color: var(--accent-ink);
            margin: 20px 0 10px 0;
            padding-bottom: 10px;
            border-bottom: 2px solid var(--border-color);
            transition: border-color 0.3s ease;
        }
        
        .chip {
            display: inline-block;
            padding: 4px 10px;
            background: #e7eaf6;
            color: var(--accent-ink);
            border-radius: 12px;
            font-size: 0.85em;
            margin: 2px;
        }
        
        .modal-tabs {
            display: flex;
            gap: 5px;
            margin-bottom: 20px;
            border-bottom: 2px solid #e0e0e0;
        }
        
        .modal-tab {
            padding: 10px 20px;
            cursor: pointer;
            border: none;
            background: transparent;
            font-size: 0.95em;
            font-weight: 600;
            color: #666;
            border-bottom: 3px solid transparent;
            transition: all 0.2s;
        }
        
        .modal-tab:hover {
            color: var(--accent-ink);
            background: rgba(139, 147, 212, 0.05);
        }
        
        .modal-tab.active {
            color: var(--accent-ink);
            border-bottom-color: var(--accent-ink);
        }
        
        .modal-tab-content {
            display: none;
        }
        
        .modal-tab-content.active {
            display: block;
        }
        
        .raw-data-container {
            background: #1e1e1e;
            color: #d4d4d4;
            padding: 20px;
            border-radius: 8px;
            overflow: auto;
            max-height: 60vh;
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            font-size: 0.9em;
            line-height: 1.5;
        }
        
        .raw-data-container pre {
            margin: 0;
            white-space: pre-wrap;
            word-wrap: break-word;
        }
        
        .search-box button:active {
            transform: translateY(0);
        }
        
        .results {
            padding: 0 30px 30px 30px;
            background: var(--container-bg);
            transition: background 0.3s ease;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
            background: var(--card-bg);
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 2px 8px var(--shadow-color);
            transition: background 0.3s ease, box-shadow 0.3s ease;
        }
        
        thead {
            background: var(--brand-gradient);
            color: white;
        }
        
        th {
            padding: 15px;
            text-align: left;
            font-weight: 600;
        }
        
        td {
            padding: 15px;
            text-align: left;
            color: var(--text-color);
            transition: color 0.3s ease;
        }
        
        tbody tr {
            border-bottom: 1px solid var(--border-color);
            transition: background 0.2s, border-color 0.3s;
            cursor: pointer;
        }
        
        tbody tr:hover {
            background: var(--hover-bg);
        }
        
        .loading {
            text-align: center;
            padding: 40px;
            color: var(--text-secondary);
            transition: color 0.3s ease;
        }
        
        .spinner {
            border: 3px solid var(--border-color);
            border-top: 3px solid var(--accent-ink);
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px auto;
            transition: border-color 0.3s ease;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        @keyframes pulse {
            0%, 100% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.7; transform: scale(1.05); }
        }

        /* Pipeline progress bar animated stripes */
        @keyframes pipeline-bar-stripes {
            0% { background-position: 28px 0; }
            100% { background-position: 0 0; }
        }
        .pipeline-bar-fill.active {
            background-image: linear-gradient(
                -45deg,
                rgba(255,255,255,0.20) 25%,
                transparent 25%,
                transparent 50%,
                rgba(255,255,255,0.20) 50%,
                rgba(255,255,255,0.20) 75%,
                transparent 75%,
                transparent
            ) !important;
            background-size: 28px 28px;
            animation: pipeline-bar-stripes 0.8s linear infinite;
        }
        
        .empty {
            text-align: center;
            padding: 40px;
            color: var(--text-secondary);
            font-size: 1.2em;
            transition: color 0.3s ease;
        }
        
        .badge {
            display: inline-block;
            padding: 4px 12px;
            border-radius: 12px;
            font-size: 0.85em;
            font-weight: 600;
        }
        
        /* Data Management Section */
        .data-management {
            padding: 30px;
            background: var(--tab-bg);
            border-top: 2px solid var(--border-color);
        }
        
        .data-management h2 {
            color: var(--text-color);
            margin-bottom: 20px;
            font-size: 1.5em;
        }
        
        .data-controls {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
        }
        
        .control-card {
            background: var(--card-bg);
            padding: 25px;
            border-radius: 8px;
            box-shadow: 0 2px 8px var(--shadow-color);
        }
        
        .control-card h3 {
            color: var(--accent-ink);
            margin-bottom: 15px;
            font-size: 1.2em;
        }
        
        .control-card p {
            color: #666;
            margin-bottom: 15px;
            line-height: 1.6;
        }
        
        .control-card input[type="number"] {
            width: 100%;
            padding: 10px;
            border: 2px solid #e0e0e0;
            border-radius: 6px;
            margin-bottom: 15px;
            font-size: 1em;
        }
        
        .control-card button {
            width: 100%;
            padding: 12px;
            background: var(--brand-gradient);
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 1em;
            cursor: pointer;
            font-weight: 600;
            transition: transform 0.2s;
        }
        
        .control-card button:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(139, 147, 212, 0.4);
        }
        
        .control-card button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        
        .status-box {
            margin-top: 15px;
            padding: 12px;
            border-radius: 6px;
            font-size: 0.9em;
            min-height: 50px;
        }
        
        .status-box.idle {
            background: #f0f0f0;
            color: #666;
        }
        
        .status-box.running {
            background: #fff3cd;
            color: #856404;
            border-left: 4px solid #ffc107;
        }
        
        .status-box.success {
            background: #d4edda;
            color: #155724;
            border-left: 4px solid #28a745;
        }
        
        .status-box.error {
            background: #f8d7da;
            color: #721c24;
            border-left: 4px solid #dc3545;
        }
        
        .badge-cpt {
            background: #e3f2fd;
            color: #1976d2;
        }
        
        .badge-hcpcs {
            background: #f3e5f5;
            color: #7b1fa2;
        }
        
        .badge-ndc {
            background: #e8f5e9;
            color: #388e3c;
        }
        
        /* Quality badges */
        .quality-badge {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 0.8em;
            font-weight: 600;
            margin-left: 8px;
        }
        
        .quality-high {
            background: #e8f5e9;
            color: #2e7d32;
            border: 1px solid #a5d6a7;
        }
        
        .quality-medium {
            background: #fff3e0;
            color: #e65100;
            border: 1px solid #ffcc80;
        }
        
        .quality-low {
            background: #ffebee;
            color: #c62828;
            border: 1px solid #ef9a9a;
        }
        
        .quality-badge::before {
            content: '';
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
        }
        
        .quality-high::before {
            background: #4caf50;
        }
        
        .quality-medium::before {
            background: #ff9800;
        }
        
        .quality-low::before {
            background: #f44336;
        }
        
        /* Rate type badges */
        .rate-type-badge {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 0.75em;
            font-weight: 600;
            margin-left: 6px;
        }
        
        .rate-negotiated {
            background: #e3f2fd;
            color: #1565c0;
            border: 1px solid #90caf9;
        }
        
        .rate-fee-schedule {
            background: #f3e5f5;
            color: #6a1b9a;
            border: 1px solid #ce93d8;
        }
        
        .rate-derived {
            background: #fff3e0;
            color: #e65100;
            border: 1px solid #ffb74d;
        }
        
        .rate-bundle {
            background: #e8f5e9;
            color: #2e7d32;
            border: 1px solid #81c784;
        }
        
        .rate-capitation {
            background: #fce4ec;
            color: #c2185b;
            border: 1px solid #f48fb1;
        }
        
        /* Expiration warning */
        .expiration-warning {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 0.85em;
            color: #f57c00;
            margin-top: 8px;
        }
        
        .expiration-expired {
            color: #d32f2f;
            font-weight: 600;
        }
        
        /* Facility consolidation badge */
        .facility-badge {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 0.75em;
            font-weight: 600;
            background: #e8eaf6;
            color: #3f51b5;
            border: 1px solid #9fa8da;
            margin-left: 6px;
        }
        
        .location-badge {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 0.75em;
            font-weight: 600;
            background: #e0f7fa;
            color: #00838f;
            border: 1px solid #80deea;
            margin-left: 6px;
        }
        
        .facility-info-section {
            margin-top: 12px;
            padding: 10px;
            background: #f5f7fa;
            border-left: 3px solid #3f51b5;
            border-radius: 4px;
            font-size: 0.85em;
        }
        
        /* Multiple rates indicator */
        .multiple-rates-indicator {
            background: #fff8e1;
            border-left: 3px solid #ffa726;
            padding: 10px;
            margin-top: 10px;
            cursor: pointer;
            border-radius: 4px;
            transition: background 0.2s;
        }
        
        .multiple-rates-indicator:hover {
            background: #ffecb3;
        }
        
        .rate-breakdown {
            margin-top: 10px;
            border-top: 1px solid #e0e0e0;
            padding-top: 10px;
        }
        
        .rate-breakdown-row {
            display: grid;
            grid-template-columns: auto 1fr auto auto;
            gap: 15px;
            padding: 8px 0;
            border-bottom: 1px solid #f5f5f5;
            align-items: center;
        }
        
        .rate-breakdown-row:last-child {
            border-bottom: none;
        }
        
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            z-index: 1000;
            animation: fadeIn 0.3s;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        
        .modal-content {
            background: var(--container-bg);
            max-width: 800px;
            margin: 50px auto;
            border-radius: 12px;
            padding: 30px;
            max-height: 80vh;
            overflow-y: auto;
            animation: slideDown 0.3s;
            transition: background 0.3s ease;
        }
        
        @keyframes slideDown {
            from {
                transform: translateY(-50px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }
        
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 2px solid var(--border-color);
            transition: border-color 0.3s ease;
        }
        
        .modal-header h2 {
            color: var(--accent-ink);
        }
        
        .close-btn {
            background: none;
            border: none;
            font-size: 28px;
            color: #999;
            cursor: pointer;
            line-height: 1;
        }
        
        .close-btn:hover {
            color: var(--text-color);
        }
        
        .detail-item {
            padding: 15px;
            background: var(--card-bg);
            border-radius: 8px;
            margin-bottom: 10px;
            transition: background 0.3s ease;
        }
        
        .detail-item strong {
            color: var(--accent-ink);
            display: block;
            margin-bottom: 5px;
        }
        
        /* Dark mode utility styles for inline elements */
        body.dark-mode .search-box > div,
        body.dark-mode [style*="background: white"],
        body.dark-mode [style*="background: #fff"] {
            background: var(--card-bg) !important;
        }
        
        body.dark-mode [style*="background: #f8f9fa"] {
            background: var(--tab-bg) !important;
        }
        
        body.dark-mode [style*="border: 2px solid #e0e0e0"],
        body.dark-mode [style*="border: 1px solid #e0e0e0"] {
            border-color: var(--input-border) !important;
        }
        
        body.dark-mode [style*="color: #333"],
        body.dark-mode [style*="color: #666"] {
            color: var(--text-secondary) !important;
        }
        
        body.dark-mode input,
        body.dark-mode select,
        body.dark-mode textarea {
            background: var(--input-bg) !important;
            color: var(--text-color) !important;
            border-color: var(--input-border) !important;
        }
        
        body.dark-mode .search-result-item {
            background: var(--card-bg) !important;
            border-color: var(--border-color) !important;
        }
        
        /* ==================== Payer Database Selector ==================== */
        
        .payer-selector-toggle {
            background: rgba(255, 255, 255, 0.2);
            border: 2px solid rgba(255, 255, 255, 0.3);
            color: white;
            padding: 8px 16px;
            border-radius: 25px;
            cursor: pointer;
            font-size: 0.95em;
            display: flex;
            align-items: center;
            gap: 8px;
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
        }
        
        .payer-selector-toggle:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.02);
        }
        
        .payer-selector-toggle .payer-icon {
            font-size: 1.1em;
        }
        
        .payer-selector-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            backdrop-filter: blur(5px);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 2000;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        
        .payer-selector-modal.active {
            display: flex;
            opacity: 1;
        }
        
        .payer-selector-content {
            background: var(--container-bg);
            border-radius: 16px;
            width: 90%;
            max-width: 800px;
            max-height: 80vh;
            overflow: hidden;
            box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
            transform: scale(0.9);
            transition: transform 0.3s ease;
        }
        
        .payer-selector-modal.active .payer-selector-content {
            transform: scale(1);
        }
        
        .payer-selector-header {
            background: var(--brand-gradient);
            color: white;
            padding: 25px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .payer-selector-header h2 {
            font-size: 1.5em;
            font-weight: 600;
            margin: 0;
        }
        
        .payer-selector-header p {
            opacity: 0.9;
            margin-top: 5px;
            font-size: 0.95em;
        }
        
        .payer-selector-close {
            background: rgba(255, 255, 255, 0.2);
            border: none;
            color: white;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            cursor: pointer;
            font-size: 1.3em;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
        }
        
        .payer-selector-close:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: rotate(90deg);
        }
        
        .payer-selector-toolbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 30px;
            background: var(--sidebar-bg);
            border-bottom: 1px solid var(--border-color);
        }
        
        .payer-selection-info {
            font-size: 0.95em;
            color: var(--text-secondary);
            font-weight: 500;
        }
        
        .payer-selection-actions {
            display: flex;
            gap: 10px;
        }
        
        .payer-toolbar-btn {
            padding: 6px 14px;
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            color: var(--text-color);
            font-size: 0.85em;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .payer-toolbar-btn:hover {
            border-color: var(--accent-ink);
            color: var(--accent-ink);
        }
        
        .payer-selector-body {
            padding: 25px 30px;
            max-height: 60vh;
            overflow-y: auto;
        }
        
        .payer-cards-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 20px;
        }
        
        .payer-card {
            background: var(--card-bg);
            border: 2px solid var(--border-color);
            border-radius: 12px;
            padding: 20px;
            padding-top: 15px;
            position: relative;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
        }
        
        .payer-card:hover {
            border-color: var(--accent-ink);
            transform: translateY(-3px);
            box-shadow: 0 10px 30px var(--shadow-color);
        }
        
        .payer-card.selected {
            border-color: var(--accent-ink);
            background: linear-gradient(135deg, rgba(139, 147, 212, 0.1) 0%, rgba(139, 147, 212, 0.1) 100%);
        }
        
        .payer-card.selected::after {
            content: 'âœ“';
            position: absolute;
            top: 15px;
            right: 15px;
            background: var(--brand-gradient);
            color: white;
            width: 28px;
            height: 28px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 0.9em;
        }
        
        .payer-card-checkbox {
            position: absolute;
            top: 15px;
            left: 15px;
            z-index: 2;
        }
        
        .payer-card-checkbox input[type="checkbox"] {
            width: 20px;
            height: 20px;
            cursor: pointer;
            accent-color: var(--accent-ink);
        }
        
        .payer-card-header {
            display: flex;
            align-items: center;
            gap: 15px;
            margin-bottom: 15px;
            margin-left: 30px;
        }
        
        .payer-card-icon {
            width: 50px;
            height: 50px;
            background: var(--brand-gradient);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5em;
        }
        
        .payer-card-title {
            flex: 1;
        }
        
        .payer-card-title h3 {
            font-size: 1.1em;
            font-weight: 600;
            color: var(--text-color);
            margin: 0 0 4px 0;
        }
        
        .payer-card-title .payer-id {
            font-size: 0.85em;
            color: var(--text-secondary);
        }
        
        .payer-card-description {
            font-size: 0.9em;
            color: var(--text-secondary);
            margin-bottom: 15px;
            line-height: 1.5;
        }
        
        .payer-card-stats {
            display: flex;
            gap: 15px;
            flex-wrap: wrap;
        }
        
        .payer-stat {
            background: var(--tab-bg);
            padding: 8px 12px;
            border-radius: 8px;
            font-size: 0.85em;
        }
        
        .payer-stat-value {
            font-weight: 600;
            color: var(--accent-ink);
        }
        
        .payer-stat-label {
            color: var(--text-secondary);
            margin-left: 5px;
        }
        
        .payer-selector-footer {
            padding: 20px 30px;
            border-top: 1px solid var(--border-color);
            display: flex;
            justify-content: flex-end;
            gap: 15px;
        }
        
        .payer-selector-btn {
            padding: 12px 25px;
            border-radius: 8px;
            font-size: 1em;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .payer-selector-btn.cancel {
            background: var(--tab-bg);
            border: 1px solid var(--border-color);
            color: var(--text-color);
        }
        
        .payer-selector-btn.cancel:hover {
            background: var(--hover-bg);
        }
        
        .payer-selector-btn.confirm {
            background: var(--brand-gradient);
            border: none;
            color: white;
        }
        
        .payer-selector-btn.confirm:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 20px rgba(139, 147, 212, 0.4);
        }
        
        .payer-selector-btn.confirm:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }
        
        /* No payers message */
        .no-payers-message {
            text-align: center;
            padding: 40px;
            color: var(--text-secondary);
        }
        
        .no-payers-message .icon {
            font-size: 3em;
            margin-bottom: 15px;
        }
        
        /* Map View Mode Buttons */
        .map-view-btn {
            padding: 6px 14px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.85em;
            font-weight: 600;
            transition: all 0.2s;
            background: rgba(255,255,255,0.2);
            color: white;
        }
        
        .map-view-btn.active {
            background: white;
            color: #00838f;
        }
        
        .map-view-btn:hover:not(.active) {
            background: rgba(255,255,255,0.4);
        }
        
        /* ============================================================ */
        /* Admin Panel Sidebar Layout                                   */
        /* ============================================================ */

        .admin-layout {
            display: grid;
            grid-template-columns: 250px 1fr;
            min-height: calc(100vh - 120px);
        }

        .admin-sidebar {
            /* One shade lighter than the main rail (#283147) so it reads as a
               nested layer that has folded out from the main sidebar. The left
               inset shadow makes the main bar appear to sit on top of it. */
            background: #2f3a57;
            color: #fff;
            align-self: stretch;
            box-shadow: inset 7px 0 14px -7px rgba(0,0,0,0.55);
        }

        .admin-sidebar-header {
            padding: 18px 20px 16px 26px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            transition: background 0.2s;
        }

        .admin-sidebar-header:hover {
            background: rgba(255, 255, 255, 0.05);
        }

        .admin-sidebar-header.active {
            background: rgba(173, 132, 198, 0.15);
            border-left: 3px solid #ad84c6;
        }

        .admin-sidebar-header h3 {
            margin: 0;
            font-size: 1.3em;
            font-weight: 700;
            color: #fff;
        }

        .admin-sidebar-header p {
            margin: 6px 0 0;
            font-size: 0.85em;
            color: rgba(255, 255, 255, 0.6);
        }

        .admin-sidebar-nav {
            padding: 8px 0;
        }

        .admin-nav-item {
            display: flex;
            align-items: center;
            gap: 12px;
            width: 100%;
            padding: 12px 20px 12px 26px;
            background: none;
            border: none;
            color: rgba(255, 255, 255, 0.7);
            cursor: pointer;
            font-size: 0.95em;
            font-weight: 500;
            text-align: left;
            transition: all 0.2s ease;
            border-left: 3px solid transparent;
            font-family: inherit;
        }

        .admin-nav-item:hover {
            background: rgba(255, 255, 255, 0.07);
            color: #fff;
        }

        .admin-nav-item.active {
            background: rgba(173, 132, 198, 0.18);
            color: #fff;
            border-left-color: #ad84c6;
            font-weight: 600;
        }

        .admin-nav-item .nav-icon {
            font-size: 1.2em;
            width: 28px;
            text-align: center;
            flex-shrink: 0;
        }

        .admin-nav-item .nav-label {
            flex: 1;
        }

        .admin-nav-item .drag-handle {
            opacity: 0;
            font-size: 0.7em;
            letter-spacing: 1px;
            color: rgba(255,255,255,0.25);
            cursor: grab;
            transition: opacity 0.2s;
            user-select: none;
            flex-shrink: 0;
            padding: 2px;
        }

        .admin-nav-item:hover .drag-handle {
            opacity: 1;
        }

        .admin-nav-item.dragging {
            opacity: 0.35;
        }

        .admin-nav-item.drag-over-above {
            box-shadow: inset 0 2px 0 0 #ad84c6;
        }

        .admin-nav-item.drag-over-below {
            box-shadow: inset 0 -2px 0 0 #ad84c6;
        }

        /* Panel drag-and-drop (Dashboard + API Usage) */
        .draggable-panel {
            position: relative;
            transition: opacity 0.2s, box-shadow 0.2s;
        }

        .panel-drag-handle {
            position: absolute;
            top: 4px;
            right: 8px;
            opacity: 0;
            font-size: 1em;
            color: #bbb;
            cursor: grab;
            user-select: none;
            z-index: 5;
            transition: opacity 0.2s, color 0.2s;
            line-height: 1;
            padding: 2px 4px;
            border-radius: 4px;
        }

        .draggable-panel:hover .panel-drag-handle {
            opacity: 1;
        }

        .panel-drag-handle:hover {
            color: var(--accent-ink);
            background: rgba(139, 147, 212, 0.08);
        }

        .draggable-panel.dragging {
            opacity: 0.3;
        }

        .draggable-panel.drag-over-above {
            box-shadow: 0 -3px 0 0 var(--accent-ink);
        }

        .draggable-panel.drag-over-below {
            box-shadow: 0 3px 0 0 var(--accent-ink);
        }

        .admin-op-badge {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #10b981;
            flex-shrink: 0;
        }

        .admin-sidebar-stats {
            padding: 16px 20px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            font-size: 0.85em;
        }

        .admin-sidebar-stats .stat-item {
            display: flex;
            justify-content: space-between;
            padding: 4px 0;
            color: rgba(255, 255, 255, 0.5);
        }

        .admin-sidebar-stats .stat-value {
            color: #ad84c6;
            font-weight: 600;
        }

        .admin-content {
            min-width: 0;
            overflow-x: hidden;
        }

        [data-admin-section] {
            display: none;
        }

        [data-admin-section].active-section {
            display: block;
        }

        /* User Management table — compact, fits the narrow admin content column */
        #usersTable {
            min-width: 640px;
            table-layout: fixed;
        }
        #usersTable th,
        #usersTable td {
            padding: 10px 12px;
            vertical-align: middle;
        }
        #usersTable th {
            white-space: nowrap;
        }
        /* Column widths: User | Email | Org | Role | 2FA | Status | Last Login | Actions */
        #usersTable th:nth-child(1), #usersTable td:nth-child(1) { width: 19%; }
        #usersTable th:nth-child(2), #usersTable td:nth-child(2) { width: 20%; }
        #usersTable th:nth-child(3), #usersTable td:nth-child(3) { width: 13%; }
        #usersTable th:nth-child(4), #usersTable td:nth-child(4) { width: 9%; }
        #usersTable th:nth-child(5), #usersTable td:nth-child(5) { width: 7%; }
        #usersTable th:nth-child(6), #usersTable td:nth-child(6) { width: 9%; }
        #usersTable th:nth-child(7), #usersTable td:nth-child(7) { width: 11%; }
        #usersTable th:nth-child(8), #usersTable td:nth-child(8) { width: 12%; }
        /* Truncate long email / organization gracefully */
        #usersTable td:nth-child(2),
        #usersTable td:nth-child(3) {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        #usersTable td:nth-child(7) {
            font-size: 0.82em;
            line-height: 1.25;
        }
        /* Compact, square action buttons that wrap if needed */
        #usersTable td:last-child .user-actions {
            display: flex;
            gap: 4px;
            justify-content: center;
            flex-wrap: wrap;
        }
        #usersTable td:last-child .user-actions button {
            padding: 6px;
            width: 30px;
            height: 30px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        #usersTable td:last-child .user-actions button svg.lucide {
            width: 15px;
            height: 15px;
        }

        /* Gridstack overrides */
        .grid-stack-item-content {
            background: transparent;
            overflow: visible;
            border: 2px solid #d1d5db;
            border-radius: 10px;
        }

        .gs-panel-fill {
            height: 100%;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .gs-metric-card {
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

        .grid-stack > .grid-stack-placeholder > .placeholder-content {
            background: rgba(139, 147, 212, 0.08);
            border: 2px dashed var(--accent-ink);
            border-radius: 12px;
        }

        .grid-stack-item > .ui-resizable-handle {
            opacity: 0;
            transition: opacity 0.2s;
        }

        .grid-stack-item:hover > .ui-resizable-handle {
            opacity: 0.5;
        }

        /* Non-platform users: force-hide all dataops sections except the request form */
        body.non-platform-user [data-admin-section="dataops"]:not(#dataOpsRequestForm) {
            display: none !important;
        }

        /* Non-platform users: force-hide any element marked .platform-only.
           Sidebar buttons are also hidden imperatively in organizations.js,
           but this rule covers in-section controls (Add Payer, Database
           Operations, etc.) and serves as a defense-in-depth backstop. */
        body.non-platform-user .platform-only {
            display: none !important;
        }

        /* Dark mode sidebar */
        .dark-mode .admin-sidebar {
            background: #1a1a2e;
        }

        .dark-mode .admin-nav-item.active {
            background: rgba(173, 132, 198, 0.12);
        }

        /* Responsive: collapse sidebar on small screens */
        @media (max-width: 900px) {
            .admin-layout {
                grid-template-columns: 1fr;
            }

            .admin-sidebar {
                position: static;
                max-height: none;
                border-radius: 0;
            }

            .admin-sidebar-nav {
                display: flex;
                flex-wrap: wrap;
                gap: 4px;
                padding: 8px 12px;
            }

            .admin-nav-item {
                width: auto;
                padding: 8px 14px;
                border-left: none;
                border-bottom: 2px solid transparent;
                border-radius: 6px;
                font-size: 0.85em;
            }

            .admin-nav-item.active {
                border-left: none;
                border-bottom-color: #ad84c6;
            }

            .admin-sidebar-stats {
                display: none;
            }
        }

        /* Collapsible shelf (details/summary) */
        .admin-collapsible summary {
            list-style: none;
        }

        .admin-collapsible summary::-webkit-details-marker {
            display: none;
        }

        .admin-collapsible summary::before {
            content: '▶';
            display: inline-block;
            margin-right: 8px;
            transition: transform 0.2s ease;
            font-size: 0.7em;
        }

        .admin-collapsible[open] summary::before {
            transform: rotate(90deg);
        }

        .dark-mode .admin-collapsible {
            background: #1e1e2e !important;
        }

        .dark-mode .admin-collapsible summary {
            color: #ad84c6;
        }

        .dark-mode .admin-collapsible ul {
            color: #b0b0b0 !important;
        }

        /* Admin Dashboard */
        .dash-metric {
            background: var(--card-bg);
            border: 2px solid var(--border-color);
            border-radius: 10px;
            padding: 14px;
            text-align: center;
            transition: border-color 0.3s;
        }

        .dash-metric-icon {
            font-size: 1.5em;
            margin-bottom: 4px;
        }

        .dash-metric-label {
            font-size: 0.75em;
            color: var(--text-secondary);
            text-transform: uppercase;
            font-weight: 600;
            letter-spacing: 0.5px;
        }

        .dash-metric-value {
            font-size: 0.9em;
            font-weight: 700;
            color: var(--text-color);
        }

        .dash-card {
            background: var(--card-bg);
            border-radius: 12px;
            padding: 20px;
            box-shadow: 0 2px 8px var(--shadow-color);
            text-align: center;
        }

        .dash-card-header {
            font-size: 0.85em;
            color: var(--text-secondary);
            font-weight: 600;
            margin-bottom: 8px;
        }

        .dash-card-big {
            font-size: 2em;
            font-weight: 800;
            color: var(--text-color);
            line-height: 1.2;
        }

        .dash-card-sub {
            font-size: 0.8em;
            color: var(--text-secondary);
            margin-top: 4px;
        }

        .dash-panel {
            background: var(--card-bg);
            border-radius: 12px;
            padding: 20px;
            box-shadow: 0 2px 8px var(--shadow-color);
        }

        .dash-panel-title {
            margin: 0 0 12px 0;
            color: var(--text-color);
            font-size: 1em;
            font-weight: 700;
        }

        .dash-docker-row {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 0;
            border-bottom: 1px solid var(--border-color);
            font-size: 0.9em;
        }

        .dash-docker-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            flex-shrink: 0;
        }

        .dash-docker-name {
            font-weight: 600;
            color: var(--text-color);
            flex: 1;
        }

        .dash-docker-status {
            color: var(--text-secondary);
            font-size: 0.85em;
        }

        .dash-docker-mem {
            color: var(--accent-ink);
            font-weight: 600;
            font-size: 0.85em;
        }

        /* Dashboard dark mode */
        .dark-mode .dash-metric {
            background: #1e1e2e;
            border-color: #444;
        }

        .dark-mode .dash-metric-value {
            color: #e0e0e0;
        }

        .dark-mode .dash-card {
            background: #1e1e2e;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        }

        .dark-mode .dash-card-big {
            color: #ad84c6;
        }

        .dark-mode .dash-panel {
            background: #1e1e2e;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        }

        .dark-mode .dash-panel-title {
            color: #ad84c6;
        }

        .dark-mode .dash-docker-name {
            color: #e0e0e0;
        }

        /* Dashboard resource bars */
        .dash-resource-bar {
            width: 100%;
            height: 8px;
            background: #e5e7eb;
            border-radius: 4px;
            overflow: hidden;
        }

        .dash-resource-fill {
            height: 100%;
            border-radius: 4px;
            transition: width 0.6s ease;
        }

        .dark-mode .dash-resource-bar {
            background: #374151;
        }

        /* Server Status section */
        .srv-container-card {
            padding: 10px 12px;
            border-bottom: 1px solid #f3f4f6;
        }


/* ============================================================
   NEWS WALL — newspaper-style article grid
   ============================================================ */

.news-wall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.news-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
}
.news-card:hover {
    box-shadow: 0 6px 24px var(--shadow-color);
    transform: translateY(-2px);
}

.news-card-banner {
    height: 6px;
    width: 100%;
}
.news-card-banner.patch-notes   { background: var(--brand-gradient); }
.news-card-banner.announcement  { background: linear-gradient(90deg, #f59e0b, #f97316); }
.news-card-banner.guide         { background: linear-gradient(90deg, #10b981, #059669); }
.news-card-banner.maintenance   { background: linear-gradient(90deg, #ef4444, #dc2626); }

.news-card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.news-card-category {
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-ink);
    margin-bottom: 8px;
}
.news-card-category.announcement { color: #f59e0b; }
.news-card-category.guide        { color: #10b981; }
.news-card-category.maintenance   { color: #ef4444; }

.news-card-title {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 8px;
    line-height: 1.3;
}
.news-card-summary {
    font-size: 0.9em;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
}
.news-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 0.78em;
    color: var(--text-secondary);
}
.news-card-draft {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: 600;
}

/* Full article reader */
.news-reader {
    max-width: 780px;
    margin: 0 auto;
}
.news-reader-header {
    margin-bottom: 24px;
}
.news-reader-article {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 40px 48px;
    line-height: 1.75;
    color: #374151;
    font-size: 1em;
}
.news-reader-article h1 {
    font-size: 2em;
    font-weight: 800;
    color: #1f2937;
    margin: 0 0 8px;
    line-height: 1.2;
}
.news-reader-article .news-article-meta {
    color: #9ca3af;
    font-size: 0.85em;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f3f4f6;
}
.news-reader-article h2 {
    font-size: 1.35em;
    font-weight: 700;
    color: #283147;
    margin: 32px 0 12px;
}
.news-reader-article h3 {
    font-size: 1.1em;
    font-weight: 600;
    color: #4b5563;
    margin: 24px 0 8px;
}
.news-reader-article p {
    margin: 0 0 14px;
}
.news-reader-article ul, .news-reader-article ol {
    margin: 0 0 14px;
    padding-left: 24px;
}
.news-reader-article li {
    margin-bottom: 4px;
}
.news-reader-article code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--accent-ink);
}
.news-reader-article pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.88em;
    margin: 0 0 14px;
}
.news-reader-article pre code {
    background: none;
    color: inherit;
    padding: 0;
}
.news-reader-article blockquote {
    border-left: 4px solid var(--accent-ink);
    margin: 0 0 14px;
    padding: 12px 20px;
    background: #f8f9ff;
    border-radius: 0 8px 8px 0;
    color: #4b5563;
}
.news-reader-article table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 14px;
    font-size: 0.9em;
}
.news-reader-article th {
    background: var(--accent-ink);
    color: #fff;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
}
.news-reader-article td {
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
}
.news-reader-article tr:nth-child(even) td { background: #f9fafb; }
.news-reader-article hr {
    border: none;
    border-top: 2px solid #f3f4f6;
    margin: 28px 0;
}

/* Admin action buttons on article reader */
.news-reader-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

/* Dark mode */
.dark-mode .news-card { background: #1f2937; border-color: #374151; }
.dark-mode .news-card-title { color: #f9fafb; }
.dark-mode .news-card-summary { color: #9ca3af; }
.dark-mode .news-card-meta { border-color: #374151; color: #6b7280; }
.dark-mode .news-reader-article { background: #1f2937; border-color: #374151; color: #d1d5db; }
.dark-mode .news-reader-article h1 { color: #f9fafb; }
.dark-mode .news-reader-article h2 { color: #c7d0e0; }
.dark-mode .news-reader-article code { background: #374151; }
.dark-mode .news-reader-article td { border-color: #374151; }
.dark-mode .news-reader-article tr:nth-child(even) td { background: #283147; }
.dark-mode .news-reader-article blockquote { background: #283147; color: #9ca3af; }

/* Docs reference popup modal */
.docs-ref-modal {
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
}

/* Docs reference links in articles */
.docs-ref-link {
    color: var(--accent-ink);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent-ink);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.docs-ref-link:hover {
    color: #5a67d8;
    border-bottom-style: solid;
}
.dark-mode .docs-ref-link { color: #818cf8; border-bottom-color: #818cf8; }
.dark-mode .docs-ref-link:hover { color: #a5b4fc; border-bottom-color: #a5b4fc; }

        .srv-container-card:last-child {
            border-bottom: none;
        }

        .srv-container-btn {
            background: none;
            border: 1px solid #e5e7eb;
            border-radius: 4px;
            cursor: pointer;
            padding: 2px 6px;
            font-size: 0.8em;
            transition: background 0.15s;
        }

        .srv-container-btn:hover {
            background: #f3f4f6;
        }

        .srv-cmd-card {
            margin-bottom: 4px;
        }

        .srv-cmd-label {
            font-size: 0.78em;
            font-weight: 600;
            color: #555;
            margin-bottom: 4px;
        }

        .srv-cmd-box {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: #1e1e2e;
            color: #a5f3c4;
            padding: 8px 12px;
            border-radius: 6px;
            font-family: 'Courier New', monospace;
            font-size: 0.8em;
            cursor: pointer;
            transition: background 0.15s;
        }

        .srv-cmd-box:hover {
            background: #283040;
        }

        .srv-cmd-box code {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .srv-cmd-copy {
            flex-shrink: 0;
            margin-left: 8px;
        }

        .dark-mode .srv-container-card {
            border-bottom-color: #374151;
        }

        .dark-mode .srv-container-btn {
            border-color: #4b5563;
            color: #e0e0e0;
        }

        .dark-mode .srv-container-btn:hover {
            background: #374151;
        }

        .dark-mode .srv-cmd-label {
            color: #aaa;
        }

        .dark-mode .srv-cmd-box {
            background: #111827;
        }

        .dark-mode .srv-cmd-box:hover {
            background: #1f2937;
        }

        /* Dashboard & Server responsive — stack two-column to single on narrow */
        @media (max-width: 900px) {
            [data-admin-section="dashboard"] > div:nth-child(n+4),
            [data-admin-section="server"] > div {
                grid-template-columns: 1fr !important;
            }
        }

        /* Leaflet Cluster Override Styles */
        .leaflet-cluster-anim .leaflet-marker-icon, 
        .leaflet-cluster-anim .leaflet-marker-shadow {
            transition: transform 0.3s ease-out, opacity 0.3s ease-in;
        }
        
        .marker-cluster {
            background-clip: padding-box;
        }

        /* ================================================================
           MAINTENANCE MODE BANNER
           ================================================================ */
        .maintenance-banner {
            background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
            color: #fff;
            padding: 12px 24px;
            font-size: 0.95rem;
            z-index: 9999;
            box-shadow: 0 2px 12px rgba(239, 68, 68, 0.35);
            animation: maintenancePulse 3s ease-in-out infinite;
        }

        @keyframes maintenancePulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.92; }
        }

        .maintenance-banner-content {
            display: flex;
            align-items: center;
            gap: 14px;
            max-width: 1200px;
            margin: 0 auto;
            flex-wrap: wrap;
        }

        .maintenance-banner-icon {
            font-size: 1.4em;
            flex-shrink: 0;
        }

        .maintenance-banner-text {
            flex: 1;
            min-width: 200px;
        }

        .maintenance-banner-text strong {
            margin-right: 8px;
        }

        .maintenance-banner-timer {
            font-weight: 700;
            font-size: 0.9em;
            background: rgba(0,0,0,0.2);
            padding: 4px 12px;
            border-radius: 6px;
            white-space: nowrap;
            flex-shrink: 0;
        }

        body.dark-mode .maintenance-banner {
            background: linear-gradient(135deg, #b45309 0%, #991b1b 100%);
            box-shadow: 0 2px 12px rgba(153, 27, 27, 0.5);
        }

        /* ==================== AI Assistant ==================== */
        .ai-chat-wrap {
            margin: 0 20px 20px;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .ai-transcript {
            border: 1px solid var(--border-color, #e2e8f0);
            border-radius: 12px;
            padding: 16px;
            min-height: 320px;
            max-height: 55vh;
            overflow-y: auto;
            background: var(--card-bg, #fff);
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .ai-msg {
            display: flex;
            max-width: 85%;
        }

        .ai-msg-user {
            align-self: flex-end;
        }

        .ai-msg-assistant {
            align-self: flex-start;
        }

        .ai-msg-body {
            padding: 10px 14px;
            border-radius: 12px;
            line-height: 1.5;
            font-size: 0.95em;
            word-wrap: break-word;
        }

        .ai-msg-user .ai-msg-body {
            background: var(--brand-gradient);
            color: #fff;
        }

        .ai-msg-assistant .ai-msg-body {
            background: var(--bg-secondary, #f1f5f9);
            color: var(--text-primary, #1e293b);
        }

        .ai-msg-body pre {
            background: #1e1e2e;
            color: #e2e8f0;
            padding: 10px;
            border-radius: 8px;
            overflow-x: auto;
            margin: 8px 0;
        }

        .ai-msg-body code {
            font-family: 'SF Mono', Consolas, monospace;
            font-size: 0.88em;
        }

        .ai-tool-status {
            align-self: flex-start;
            font-size: 0.82em;
            color: var(--text-secondary, #64748b);
            font-style: italic;
            padding: 2px 6px;
        }

        .ai-error {
            color: #dc2626;
            font-size: 0.9em;
        }

        /* AI assistant toolbar (export actions) */
        .ai-toolbar {
            display: flex;
            gap: 8px;
            justify-content: flex-end;
            margin-bottom: 8px;
            flex-wrap: wrap;
        }
        .ai-export-btn {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 5px 10px;
            font-size: 0.8em;
            background: var(--card-bg, #fff);
            border: 1px solid var(--border-color, #e5e7eb);
            border-radius: 6px;
            color: var(--text-secondary, #64748b);
            cursor: pointer;
        }
        .ai-export-btn:hover {
            background: var(--hover-bg, #f1f5f9);
            color: var(--text-color, #333);
        }

        /* AI-rendered chart cards */
        .ai-chart-card {
            width: 100%;
            max-width: 640px;
            background: var(--card-bg, #fff);
            border: 1px solid var(--border-color, #e5e7eb);
            border-radius: 10px;
            padding: 14px 16px;
        }
        .ai-chart-title {
            font-weight: 600;
            font-size: 0.95em;
            margin-bottom: 8px;
            color: var(--text-color, #333);
        }
        .ai-chart-canvas-wrap {
            position: relative;
            height: 300px;
            width: 100%;
        }
        .ai-chart-actions {
            display: flex;
            justify-content: flex-end;
            margin-top: 8px;
        }
        .ai-chart-dl {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 5px 10px;
            font-size: 0.8em;
            background: var(--hover-bg, #f1f5f9);
            border: 1px solid var(--border-color, #e5e7eb);
            border-radius: 6px;
            color: var(--text-color, #333);
            cursor: pointer;
        }
        .ai-chart-dl:hover {
            background: var(--border-color, #e5e7eb);
        }

        .ai-input-row {
            display: flex;
            gap: 10px;
            align-items: flex-end;
        }

        .ai-input-row textarea {
            flex: 1;
            padding: 12px;
            border: 1px solid var(--border-color, #e2e8f0);
            border-radius: 10px;
            font-family: inherit;
            font-size: 0.95em;
            resize: vertical;
            background: var(--card-bg, #fff);
            color: var(--text-primary, #1e293b);
        }

        .ai-input-row button {
            padding: 12px 24px;
            background: var(--brand-gradient);
            color: #fff;
            border: none;
            border-radius: 10px;
            cursor: pointer;
            font-weight: 600;
            font-size: 0.95em;
        }

        .ai-input-row button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .ai-settings {
            border: 1px solid var(--border-color, #e2e8f0);
            border-radius: 10px;
            padding: 12px 16px;
            background: var(--card-bg, #fff);
        }

        .ai-settings summary {
            cursor: pointer;
            font-weight: 600;
            color: var(--text-primary, #1e293b);
        }

        .ai-key-row {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            align-items: center;
        }

        .ai-key-row select,
        .ai-key-row input {
            padding: 8px 10px;
            border: 1px solid var(--border-color, #e2e8f0);
            border-radius: 8px;
            background: var(--card-bg, #fff);
            color: var(--text-primary, #1e293b);
            font-size: 0.9em;
        }

        .ai-key-row input {
            flex: 1;
            min-width: 160px;
        }

        .ai-key-row button {
            padding: 8px 16px;
            background: #4caf50;
            color: #fff;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 600;
        }

        .ai-key-saved {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 12px;
            background: var(--bg-secondary, #f1f5f9);
            border-radius: 8px;
            margin-bottom: 6px;
            font-size: 0.88em;
        }

        .ai-key-saved button {
            padding: 4px 12px;
            background: #f44336;
            color: #fff;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.85em;
        }

        body.dark-mode .ai-transcript,
        body.dark-mode .ai-settings,
        body.dark-mode .ai-input-row textarea {
            background: #1e1e2e;
            border-color: #2d2d44;
            color: #e2e8f0;
        }

        body.dark-mode .ai-msg-assistant .ai-msg-body,
        body.dark-mode .ai-key-saved {
            background: #2d2d44;
            color: #e2e8f0;
        }
