/* Copyright (c) 2025 NadiAI, Inc. All rights reserved.
 * Proprietary and confidential. See LICENSE.md · https://nadiai.ai/terms */

/* Agent OS — Enterprise Stylesheet */
/* Light/Dark theme support via CSS variables */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* Dark theme (default) */
:root, [data-theme="dark"] {
    --bg: #0c0c0e;
    --surface: #13131a;
    --surface2: #1a1a24;
    --surface3: #1f1f2e;
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text: #f0eefc;
    --muted: rgba(240, 238, 252, 0.5);
    --dim: rgba(240, 238, 252, 0.22);
    --teal: #4fd9b3;
    --teal-dim: rgba(79, 217, 179, 0.12);
    --purple: #9d8fff;
    --coral: #ff7b5c;
    --blue: #5ba3f5;
    --amber: #f5c147;
    --green: #6ee7b7;
    --red: #f87171;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --graph-edge: rgba(255, 255, 255, 0.06);
    --graph-label: rgba(240, 238, 252, 0.35);
    --graph-node-stroke: rgba(0, 0, 0, 0.4);
}

/* Light theme */
[data-theme="light"] {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface2: #f0f0f3;
    --surface3: #e8e8ed;
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text: #1a1a2e;
    --muted: rgba(26, 26, 46, 0.55);
    --dim: rgba(26, 26, 46, 0.28);
    --teal: #0d9373;
    --teal-dim: rgba(13, 147, 115, 0.1);
    --purple: #7c5cfc;
    --coral: #e05a3a;
    --blue: #2b7de9;
    --amber: #c49000;
    --green: #16a34a;
    --red: #dc2626;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --graph-edge: rgba(0, 0, 0, 0.08);
    --graph-label: rgba(26, 26, 46, 0.45);
    --graph-node-stroke: rgba(255, 255, 255, 0.8);
}

:root {
    --radius: 6px;
    --radius-sm: 4px;
    --radius-lg: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --transition: 0.15s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--teal); text-decoration: none; transition: color var(--transition); }
a:hover { color: #6ae4c4; text-decoration: none; }

code {
    font-family: var(--mono);
    font-size: 11.5px;
    background: var(--surface2);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--teal);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

::selection {
    background: rgba(79, 217, 179, 0.25);
    color: var(--text);
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

/* ================================================================
   NAV — 48px, subtle, enterprise
   ================================================================ */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 48px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-left { gap: 0; }

.nav-brand {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 20px;
    letter-spacing: -0.2px;
}
.nav-brand:hover { text-decoration: none; color: var(--text); }
.nav-brand-icon { height: 24px; width: auto; border-radius: var(--radius-sm); }

.nav-link {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    padding: 14px 12px;
    text-decoration: none;
    position: relative;
    transition: color var(--transition);
    height: 48px;
    display: flex;
    align-items: center;
}
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.active {
    color: var(--teal);
}
.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 12px;
    right: 12px;
    height: 2px;
    background: var(--teal);
    border-radius: 1px 1px 0 0;
}

.nav-right { gap: 12px; }

/* Theme toggle */
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 7px; color: var(--muted); cursor: pointer; display: flex; align-items: center; transition: var(--transition); }
.theme-toggle:hover { color: var(--text); border-color: var(--border-hover); }

/* Avatar trigger in nav */
.nav-avatar-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: background var(--transition);
    position: relative;
    user-select: none;
}
.nav-avatar-trigger:hover { background: var(--surface2); }

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}
.nav-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.nav-avatar-placeholder {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    background: var(--purple); color: white; font-size: 11px; font-weight: 600;
}

.nav-user { display: flex; flex-direction: column; line-height: 1.2; }
.nav-name { color: var(--text); font-size: 12.5px; font-weight: 500; }
.nav-org { color: var(--dim); font-size: 11px; }

.accent { color: var(--teal); }

/* Legacy compat */
.nav-user-link { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-user-link:hover { text-decoration: none; }
.nav-user-link:hover .nav-name { color: var(--text); }

/* ================================================================
   PROFILE DROPDOWN
   ================================================================ */
.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: var(--surface);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}
.profile-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-dropdown-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}
.profile-dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}
.profile-dropdown-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-dropdown-avatar .avatar-placeholder-lg {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    background: var(--purple); color: white; font-size: 16px; font-weight: 700;
}
.profile-dropdown-info { flex: 1; min-width: 0; }
.profile-dropdown-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-dropdown-email {
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-dropdown-role {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 500;
    text-transform: capitalize;
    margin-top: 4px;
}

.profile-dropdown-body {
    padding: 6px;
}
.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    font-size: 12.5px;
    color: var(--muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
}
.profile-dropdown-item:hover {
    color: var(--text);
    background: var(--surface2);
    text-decoration: none;
}
.profile-dropdown-item svg {
    width: 15px;
    height: 15px;
    opacity: 0.5;
    flex-shrink: 0;
}
.profile-dropdown-item:hover svg { opacity: 0.8; }

.profile-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 6px;
}

.profile-dropdown-item--danger:hover {
    color: var(--red);
    background: rgba(248, 113, 113, 0.06);
}
.profile-dropdown-item--danger:hover svg { opacity: 0.8; }

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main { padding: 28px 32px 28px; max-width: 1080px; margin: 0 auto; padding-bottom: 28px; }

/* ================================================================
   PAGE HEADER
   ================================================================ */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; color: var(--text); }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ================================================================
   STATS GRID
   ================================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border-hover); }
.stat-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
}
.stat-card:nth-child(1)::before { background: var(--teal); }
.stat-card:nth-child(2)::before { background: var(--purple); }
.stat-card:nth-child(3)::before { background: var(--blue); }
.stat-card:nth-child(4)::before { background: var(--amber); }

.stat-value { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.stat-label {
    font-size: 11px;
    color: var(--dim);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 500;
}

/* ================================================================
   SECTION
   ================================================================ */
.section { margin-bottom: 28px; }
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.1px; }

/* ================================================================
   TABLE — no outer border, subtle separators
   ================================================================ */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    padding: 8px 14px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--dim);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--muted);
    transition: background var(--transition);
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.table tbody tr:last-child td { border-bottom: none; }
.table .empty { text-align: center; color: var(--dim); padding: 32px; }
.actions-cell { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* User table avatar initials */
.table-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: white;
    background: var(--purple);
    flex-shrink: 0;
    vertical-align: middle;
    margin-right: 8px;
}

/* ================================================================
   CARD
   ================================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.card p { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.card p:last-child { margin-bottom: 0; }

/* ================================================================
   GRID
   ================================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ================================================================
   BADGE
   ================================================================ */
.badge {
    display: inline-block;
    font-size: 10.5px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
    text-transform: capitalize;
    letter-spacing: 0.1px;
}
.badge-super_admin { background: rgba(245, 193, 71, 0.12); color: var(--amber); }
.badge-tenant_admin { background: rgba(157, 143, 255, 0.12); color: var(--purple); }
.badge-end_user { background: rgba(79, 217, 179, 0.12); color: var(--teal); }
.badge-active { background: rgba(110, 231, 183, 0.10); color: var(--green); }
.badge-inactive { background: rgba(248, 113, 113, 0.10); color: var(--red); }
.badge-candidate { background: rgba(79, 217, 179, 0.12); color: var(--teal); }
.badge-node { background: rgba(91, 163, 245, 0.12); color: var(--blue); }
.badge-edge { background: rgba(255, 123, 92, 0.12); color: var(--coral); }

/* ================================================================
   BUTTONS — ghost default, filled primary
   ================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 12.5px;
    font-family: var(--font);
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
    background: var(--surface2);
    text-decoration: none;
}
.btn-primary {
    background: var(--teal);
    color: #0c0c0e;
    border-color: var(--teal);
    font-weight: 600;
}
.btn-primary:hover {
    background: #3cc9a3;
    border-color: #3cc9a3;
    color: #0c0c0e;
}
.btn-danger { color: var(--red); border-color: rgba(248, 113, 113, 0.2); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.08); border-color: var(--red); }
.btn-sm { padding: 3px 10px; font-size: 11.5px; }
.btn-full { width: 100%; justify-content: center; }

/* ================================================================
   FORMS — subtle border, teal focus ring
   ================================================================ */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--font);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 2px rgba(79, 217, 179, 0.12);
}
.form-group input::placeholder { color: var(--dim); }

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 0;
    max-width: none;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(79, 217, 179, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(157, 143, 255, 0.04) 0%, transparent 50%),
        var(--bg);
}
.login-container { width: 100%; max-width: 380px; text-align: center; padding: 20px; }
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    text-align: left;
    box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-header h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text);
}
.login-logo { max-width: 160px; height: auto; margin-bottom: 8px; }
.login-sub { color: var(--dim); font-size: 12.5px; margin-top: 6px; }
.login-form .btn { margin-top: 6px; padding: 9px 16px; }
.login-links {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
    font-size: 12px;
}
.login-links a { color: var(--dim); transition: color var(--transition); }
.login-links a:hover { color: var(--teal); }
.login-footer { color: var(--dim); font-size: 11.5px; margin-top: 20px; }

/* ================================================================
   FLASH MESSAGES
   ================================================================ */
.flash {
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    margin-bottom: 14px;
    border-left: 3px solid;
}
.flash-error { background: rgba(248, 113, 113, 0.06); color: var(--red); border-left-color: var(--red); }
.flash-success { background: rgba(110, 231, 183, 0.06); color: var(--green); border-left-color: var(--green); }
.flash-info { background: rgba(91, 163, 245, 0.06); color: var(--blue); border-left-color: var(--blue); }

/* ================================================================
   MODAL
   ================================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.modal-header h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.modal-close {
    background: none;
    border: none;
    color: var(--dim);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal h4 { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--muted); }

/* ================================================================
   SERVICES PAGE — VS Code / Linear sidebar style
   ================================================================ */
.services-page { padding: 0; max-width: none; }
.services-layout { display: flex; min-height: calc(100vh - 48px); }

.services-nav {
    width: 210px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    flex-shrink: 0;
}
.services-nav-header {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--dim);
    padding: 4px 14px 10px;
    font-family: var(--mono);
    font-weight: 500;
}
.services-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    color: var(--muted);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 500;
    border-left: 2px solid transparent;
    transition: all var(--transition);
    margin: 0;
}
.services-nav-item:hover {
    color: var(--text);
    background: rgba(255,255,255,0.02);
    text-decoration: none;
}
.services-nav-item.active {
    color: var(--teal);
    border-left-color: var(--teal);
    background: rgba(79,217,179,0.04);
}
.services-nav-item .service-icon { width: 28px; height: 28px; font-size: 9px; }
.services-nav-item .status-dot { margin-left: 4px; }

.services-content {
    flex: 1;
    padding: 28px 32px;
    max-width: 800px;
    background: var(--bg);
}
.services-grid { display: flex; flex-direction: column; gap: 14px; }

.service-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition);
}
.service-card:hover { border-color: var(--border-hover); }

.service-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.service-header h3 { font-size: 14px; font-weight: 600; }
.service-header .badge { margin-left: auto; }
.service-desc { font-size: 11.5px; color: var(--dim); margin-top: 2px; }

.service-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; font-family: var(--mono);
    flex-shrink: 0;
}
.sf-icon { background: rgba(91, 163, 245, 0.10); color: var(--blue); }
.llm-icon { background: rgba(79, 217, 179, 0.10); color: var(--teal); }
.mem-icon { background: rgba(157, 143, 255, 0.10); color: var(--purple); }
.tel-icon { background: rgba(245, 193, 71, 0.10); color: var(--amber); }
.enc-icon { background: rgba(255, 123, 92, 0.10); color: var(--coral, #ff7b5c); }

.service-body { padding: 16px 18px; }
.service-body .table { margin-bottom: 10px; }
.service-note { font-size: 11.5px; color: var(--dim); font-style: italic; margin-top: 10px; }
.service-details { display: flex; flex-direction: column; gap: 6px; }
.detail-row { display: flex; align-items: center; gap: 12px; font-size: 12.5px; }
.detail-label { color: var(--dim); min-width: 130px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }
.detail-value { color: var(--muted); }
.detail-value code.wrap { word-break: break-all; font-size: 10px; }

.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.status-green { background: var(--green); box-shadow: 0 0 4px rgba(110, 231, 183, 0.4); }
.status-gray { background: var(--dim); }

.service-test-form { display: flex; gap: 8px; margin-top: 12px; }
.service-test-input {
    flex: 1; padding: 6px 12px; font-size: 13px; font-family: var(--font);
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); outline: none; transition: border-color var(--transition), box-shadow var(--transition);
}
.service-test-input:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(79, 217, 179, 0.12); }
.service-actions { margin-top: 14px; }
.service-action-row { display: flex; gap: 8px; align-items: center; }
.service-test-result {
    margin-top: 12px; padding: 12px; background: var(--surface2);
    border-radius: var(--radius); border: 1px solid var(--border);
}

/* ================================================================
   TENANT ADMIN TABS
   ================================================================ */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.tab-link {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    position: relative;
    transition: color var(--transition);
}
.tab-link:hover { color: var(--text); text-decoration: none; }
.tab-link.active { color: var(--teal); }
.tab-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--teal);
    border-radius: 1px 1px 0 0;
}

/* ================================================================
   CHAT (App page)
   ================================================================ */
.app-page { padding: 0; max-width: none; }
.app-container { display: flex; flex-direction: column; height: calc(100vh - 48px); }
.chat-container { display: flex; flex-direction: column; flex: 1; }
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 40px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}
.chat-welcome { text-align: center; padding: 60px 0; color: var(--muted); }
.chat-welcome h2 { font-size: 18px; color: var(--text); margin-bottom: 8px; }
.chat-message { margin-bottom: 14px; }
.chat-user { text-align: right; }
.chat-bubble {
    display: inline-block;
    max-width: 75%;
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    line-height: 1.55;
}
.chat-user .chat-bubble { background: var(--teal); color: #0c0c0e; }
.chat-assistant .chat-bubble { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.chat-bubble strong { font-weight: 600; }
.chat-input-container {
    padding: 14px 40px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}
.chat-form { display: flex; gap: 8px; }
.chat-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 13px;
    font-family: var(--font);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.chat-input:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(79, 217, 179, 0.12); }
.chat-input::placeholder { color: var(--dim); }
.chat-send { padding: 10px 20px; }

/* ================================================================
   APP CANVAS — full height, minimal chrome
   ================================================================ */
.app-canvas {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--transition);
}
.app-canvas:hover { border-color: var(--border-hover); }
.app-canvas.full-height {
    min-height: calc(100vh - 48px);
    border: none;
    border-radius: 0;
    background: var(--bg);
}
.canvas-empty { text-align: center; color: var(--dim); padding: 40px; }
.canvas-empty h2 { font-size: 18px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.canvas-empty p { font-size: 13px; margin-bottom: 4px; }
.canvas-hint { font-size: 11.5px; color: var(--dim); margin-top: 8px; font-family: var(--mono); }

/* ================================================================
   PROFILE PAGE
   ================================================================ */
.profile-container { max-width: 640px; }
.profile-grid { display: flex; flex-direction: column; gap: 14px; }
.profile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    transition: border-color var(--transition);
}
.profile-card:hover { border-color: var(--border-hover); }
.profile-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--text); }
.avatar-section { display: flex; align-items: center; gap: 18px; }
.avatar-preview { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.avatar-img { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    background: var(--purple); color: white; font-size: 26px; font-weight: 700;
}
.avatar-form { display: flex; flex-direction: column; gap: 10px; }
.avatar-upload-controls { display: flex; align-items: center; gap: 10px; }
.avatar-file-input { display: none; }
.input-disabled { opacity: 0.4; cursor: not-allowed; }
.mfa-setup-container { display: flex; gap: 20px; align-items: flex-start; margin-top: 8px; }
.mfa-manual { flex: 1; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
/* ================================================================
   SOQL CONFIG / FORM BUILDER
   ================================================================ */
.form-section { margin-bottom: 28px; }
.form-section-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-hint { font-size: 11px; color: var(--dim); margin-top: 4px; }
.input-mono { font-family: var(--mono); font-size: 12px; }
.soql-textarea { min-height: 160px; max-height: 500px; resize: vertical; line-height: 1.6; padding: 12px 14px; width: 100%; overflow-y: auto; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface2); transition: var(--transition); }
.checkbox-label:hover { border-color: var(--border-hover); }
.checkbox-label input[type="checkbox"] { accent-color: var(--teal); }

/* AI Assist button */
.btn-ai { background: rgba(157, 143, 255, 0.1); color: var(--purple); border: 1px solid rgba(157, 143, 255, 0.25); display: inline-flex; align-items: center; gap: 6px; }
.btn-ai:hover { background: rgba(157, 143, 255, 0.18); border-color: rgba(157, 143, 255, 0.4); }
.btn-ai:disabled { opacity: 0.6; cursor: wait; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin { animation: spin 1.2s linear infinite; }

/* Environment toggle (SF production/sandbox selector) */
.env-toggle { cursor: pointer; }
.env-toggle input { display: none; }
.env-toggle-label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface2); color: var(--muted); font-size: 12px; font-weight: 500; transition: var(--transition); }
.env-toggle-label:hover { border-color: var(--border-hover); color: var(--text); }
.env-toggle input:checked + .env-toggle-label { border-color: var(--teal); color: var(--teal); background: rgba(79, 217, 179, 0.06); }

/* Tab panels (used in SF config page) */
.tab-panel { display: none; animation: fadeIn 0.2s ease; }
.tab-panel.tab-active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ================================================================
   BRANDED DIALOG (replaces native alert/confirm/prompt)
   ================================================================ */
.dialog-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9999; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.dialog-overlay.open { display: flex; }
.dialog-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; min-width: 340px; max-width: 440px; width: 90%; box-shadow: var(--shadow-lg); animation: fadeIn 0.15s ease; }
.dialog-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.dialog-message { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 18px; }
.dialog-input { width: 100%; padding: 8px 12px; font-size: 13px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); margin-bottom: 18px; font-family: var(--font); }
.dialog-input:focus { outline: none; border-color: var(--teal); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-btn { padding: 8px 18px; font-size: 12px; font-weight: 600; border-radius: var(--radius); cursor: pointer; border: 1px solid var(--border); font-family: var(--font); transition: var(--transition); }
.dialog-btn-cancel { background: transparent; color: var(--muted); }
.dialog-btn-cancel:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.dialog-btn-confirm { background: var(--teal); color: var(--bg); border-color: var(--teal); }
.dialog-btn-confirm:hover { opacity: 0.85; }
.dialog-btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.dialog-btn-danger:hover { opacity: 0.85; }

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */
.toast-container { position: fixed; top: 56px; right: 16px; z-index: 9998; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 16px; border-radius: var(--radius); font-size: 12px; color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); animation: slideIn 0.2s ease; max-width: 360px; display: flex; align-items: center; gap: 8px; }
.toast-success { background: var(--surface); border-color: var(--teal); }
.toast-success::before { content: '\2713'; color: var(--teal); font-weight: 700; }
.toast-error { background: var(--surface); border-color: var(--red); }
.toast-error::before { content: '\2717'; color: var(--red); font-weight: 700; }
.toast-info { background: var(--surface); border-color: var(--blue); }
.toast-info::before { content: '\2139'; color: var(--blue); font-weight: 700; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast-exit { animation: slideOut 0.2s ease forwards; }
@keyframes slideOut { to { opacity: 0; transform: translateX(20px); } }

/* Footer */
.app-footer { position: fixed; bottom: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 3px 16px; font-size: 9px; color: var(--dim); border-top: 1px solid var(--border); background: var(--surface); z-index: 5; }
.app-footer a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
.app-footer a:hover { color: var(--teal); }
.app-footer-sep { color: var(--border); }

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .main { padding: 20px 16px; }
    .nav { padding: 0 14px; }
    .chat-messages, .chat-input-container { padding-left: 16px; padding-right: 16px; }
    .services-layout { flex-direction: column; }
    .services-nav { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 8px 0; }
    .services-nav-item { border-left: none; }
    .services-content { padding: 20px 16px; }
    .profile-dropdown { right: -8px; width: 260px; }
    .nav-user { display: none; }
}
