:root {
    /* FluxPro SaaS Palette - High Fidelity */
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.25);
    
    --bg-main: #020617;
    --bg-side: #0f172a;
    --bg-2: #111827;
    --bg-card: rgba(30, 41, 59, 0.4);
    --bg-card-hover: rgba(51, 65, 85, 0.6);
    --shadow-main: 0 20px 60px rgba(0, 0, 0, 0.4);
    
    --border: rgba(148, 163, 184, 0.1);
    --border-bright: rgba(148, 163, 184, 0.2);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #0ea5e9;
    
    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 12px;
    
    --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-side: #ffffff;
    --bg-2: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border: rgba(0, 0, 0, 0.05);
    --text-primary: #0f172a;
    --text-secondary: #475569;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Layout Framework */
.app-shell {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* Sidebar - SaaS Enterprise Style */
.sidebar {
    width: 280px;
    background: var(--bg-side);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.25rem;
    z-index: 1000;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 0.75rem 2.5rem;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 8px 16px var(--accent-glow);
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-name span { color: var(--accent); }

.nav-group { margin-bottom: 2rem; }

.nav-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0 0.75rem 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: 0.2s var(--transition);
    border: none;
    background: transparent;
    cursor: pointer;
    width: 100%;
    text-align: left;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 8px 20px var(--accent-glow);
}

.nav-item i { width: 20px; }

/* Content Main Wrapper */
.main-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.header-pro {
    height: 72px;
    padding: 0 2.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-main);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.search-field {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    padding: 0.65rem 1rem;
    border-radius: var(--radius-md);
    width: 400px;
    transition: 0.2s;
}

input.search-field,
select.search-field,
textarea.search-field {
    display: block;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.65rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.search-field:focus-within {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
}

.search-field input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
    font-size: 0.9rem;
    font-weight: 500;
}

.scroll-container {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
}

/* Typography SaaS */
h1 { font-size: 2.25rem; font-weight: 800; letter-spacing: -1px; }
h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px; }

/* Component: Stat Card */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: 0.3s var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateY(-4px);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    margin-top: 0.5rem;
    display: block;
}

.stat-trend {
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 1rem;
}

/* Charts & Widgets */
.widget {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    height: 100%;
}

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

/* Agent Grid Card */
.node-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    cursor: pointer;
    transition: 0.2s var(--transition);
}

.node-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-online { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.status-offline { background: rgba(239, 68, 68, 0.1); color: var(--error); }

/* Progress Mini */
.progress-mini {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 100px;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-fill {
    height: 100%;
    transition: 0.5s var(--transition);
}

/* Detail Master Layout */
.detail-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

/* Tab Pro */
.tab-row {
    display: flex;
    gap: 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2.5rem;
}

.tab-link {
    padding: 1rem 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    position: relative;
    transition: 0.2s;
}

.tab-link:hover { color: var(--text-primary); }
.tab-link.active { color: var(--accent); }
.tab-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
}

/* Dashboard Utilities */
.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.4s var(--transition); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Buttons SaaS */
.btn-pro {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid transparent;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }

.btn-secondary { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }

/* Multi-step/Auth Overlay */
.auth-container {
    position: fixed;
    inset: 0;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

.auth-card {
    background: var(--bg-side);
    padding: 3rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 40px 100px rgba(0,0,0,0.6);
}

/* Service Badges */
.srv-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    margin-right: 4px;
}
.srv-ok { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.srv-err { background: rgba(239, 68, 68, 0.1); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.2); }
/* MOCKUP TENANT (TERMINAL STYLE) */
.mockup-tenant {
    background: #0f172a;
    border-radius: var(--radius-md);
    padding: 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: #e2e8f0;
    font-family: var(--font-mono);
    position: relative;
    border: 1px solid #334155;
    overflow: hidden;
}
.mockup-header { 
    display: flex; 
    justify-content: space-between;
    align-items: center;
    background: #1e293b;
    padding: 10px 15px;
    border-bottom: 1px solid #334155;
}
.window-controls { display: flex; gap: 10px; }
.win-btn { width: 12px; height: 12px; border-radius: 50%; background: #475569; }
.win-btn.close { background: #ef4444; }
.win-btn.min { background: #fbbf24; }
.win-btn.max { background: #22c55e; }

.mockup-body { padding: 1.5rem; font-size: 0.85rem; line-height: 1.6; }

/* ENTERPRISE TABLE */
.enterprise-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.enterprise-table th {
    text-align: left;
    padding: 1rem;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}
.enterprise-table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    font-weight: 500;
}
.enterprise-table tr:last-child td { border-bottom: none; }
.enterprise-table tr:hover td { background: rgba(255,255,255,0.01); }

/* TOAST SYSTEM */
.toast-master {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--bg-side);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4), 0 0 20px var(--accent-glow);
    z-index: 9999;
    pointer-events: none;
    transition: 0.3s var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
}
.toast-master.hidden {
    opacity: 0;
    transform: translateY(20px);
}
.toast-master.error {
    border-color: var(--error);
    box-shadow: 0 10px 40px rgba(0,0,0,0.4), 0 0 20px rgba(239, 68, 68, 0.2);
}
.toast-master.success {
    border-color: var(--success);
    box-shadow: 0 10px 40px rgba(0,0,0,0.4), 0 0 20px rgba(16, 185, 129, 0.2);
}

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
}

/* Admin theme harmonization after CSS extraction */
[data-theme="light"] .nav-item:hover {
    background: rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .fx-adm-js-inline-29,
[data-theme="light"] .fx-adm-js-inline-39,
[data-theme="light"] .fx-adm-js-inline-55,
[data-theme="light"] .fx-adm-js-inline-153,
[data-theme="light"] .fx-adm-js-inline-160,
[data-theme="light"] .fx-adm-js-inline-166,
[data-theme="light"] .fx-adm-js-inline-176,
[data-theme="light"] .slide-panel {
    background: var(--bg-side) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-bright) !important;
}

[data-theme="light"] .billing-catalog-select {
    background: var(--bg-card) !important;
    color: var(--accent) !important;
}

/* Onboarding modal layout + pipeline state (must live in styles.css for tenants.html) */
.fx-adm-js-inline-55 {
    width: min(1220px, 98vw);
    max-height: 90vh;
}

.fx-adm-onb-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr);
    gap: 12px;
    align-items: start;
}

.fx-adm-onb-main {
    min-width: 0;
}

.fx-adm-onb-chat {
    min-width: 0;
    position: sticky;
    top: 4px;
}

.fx-adm-onb-chat .fx-adm-js-inline-68 {
    margin-top: 0;
}

.fx-adm-onb-chat #adminWorkflowDiscussionMessages {
    max-height: 380px;
}

.fx-adm-onb-step-current {
    background: rgba(99, 102, 241, 0.18);
    border: 1px solid rgba(99, 102, 241, 0.45);
    color: var(--accent-light);
}

.fx-adm-onb-step-done {
    background: rgba(16, 185, 129, 0.14);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--success);
}

.fx-adm-onb-step-pending {
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--text-muted);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.65);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease;
    z-index: 900;
}

@media (max-width: 1024px) {
    body {
        overflow: auto;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        min-width: 280px;
        max-width: 280px;
        transform: translateX(-100%);
        transition: transform .22s ease;
        z-index: 1001;
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    .header-pro {
        height: auto;
        min-height: 64px;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .header-pro > div {
        width: 100%;
    }

    .header-pro > div:last-child {
        justify-content: space-between;
        gap: 0.75rem;
    }

    .search-field {
        width: calc(100vw - 120px);
        max-width: 100%;
    }

    .scroll-container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.55rem;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.2rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.9rem;
        margin-bottom: 1rem;
    }

    .fx-adm-onb-columns {
        grid-template-columns: 1fr;
    }

    .fx-adm-onb-chat {
        position: static;
    }

    .fx-adm-onb-chat #adminWorkflowDiscussionMessages {
        max-height: 260px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .tab-row {
        overflow-x: auto;
        white-space: nowrap;
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .widget,
    .stat-card,
    .node-card,
    .auth-card {
        padding: 1rem;
    }

    .btn-pro {
        width: 100%;
        justify-content: center;
    }

    #lastUpdateLabel {
        font-size: 0.65rem !important;
    }

    .enterprise-table {
        min-width: 720px;
    }

    .widget {
        overflow-x: auto;
    }

    [style*="display:grid"][style*="1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 0.9rem !important;
    }

    [style*="display:grid"][style*="1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 0.9rem !important;
    }

    [style*="width:300px"],
    [style*="width:400px"],
    [style*="width:480px"],
    [style*="width:580px"],
    [style*="width:760px"] {
        max-width: 100% !important;
    }

    .toast-master {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        width: auto;
    }
}

/* UI safety layer: prevent unreadable forced dark text on dark backgrounds */
body [style*="color:#000"],
body [style*="color: #000"],
body [style*="color:#111"],
body [style*="color: #111"],
body [style*="color:black"],
body [style*="color: black"] {
    color: var(--text-primary) !important;
}

[data-theme="dark"] body [style*="background:#fff"],
[data-theme="dark"] body [style*="background: #fff"],
[data-theme="dark"] body [style*="background-color:#fff"],
[data-theme="dark"] body [style*="background-color: #fff"] {
    color: #0f172a !important;
}

/* Support center: keep background context visible behind admin thread modal */
.fx-adm-overlay-thread {
    background: rgba(2, 6, 23, 0.5) !important;
    backdrop-filter: blur(3px) !important;
}

.fx-adm-thread-modal {
    width: min(1100px, 96vw);
    max-height: min(88vh, 940px);
    display: flex;
    flex-direction: column;
    background: var(--bg-side);
    border: 1px solid var(--border-bright);
    border-radius: 16px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.fx-adm-thread-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.fx-adm-thread-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fx-adm-thread-tenant {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-family: var(--font-mono);
}

.fx-adm-thread-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fx-adm-thread-status {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 6px 10px;
}

.fx-adm-thread-close {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
}

.fx-adm-thread-assign {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fx-adm-thread-assign-title {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.fx-adm-thread-assignees {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.fx-adm-thread-assignee {
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fx-adm-thread-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
}

.fx-adm-thread-messages {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.fx-adm-thread-footer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.fx-adm-thread-textarea {
    width: 100%;
    min-height: 78px;
    resize: vertical;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 10px 12px;
    font-family: var(--font-main);
}

.fx-adm-thread-send {
    display: flex;
    align-items: flex-end;
}

@media (max-width: 900px) {
    .fx-adm-thread-modal {
        width: 98vw;
        max-height: 92vh;
    }

    .fx-adm-thread-header {
        flex-wrap: wrap;
    }

    .fx-adm-thread-footer {
        grid-template-columns: 1fr;
    }
}

/* UI Safety Layer: contrast + overflow + modal responsiveness */
body [style*="color:#000"],
body [style*="color: #000"],
body [style*="color:#111"],
body [style*="color: #111"],
body [style*="color:#222"],
body [style*="color: #222"],
body [style*="color:black"],
body [style*="color: black"] {
    color: var(--text-primary) !important;
}

[data-theme="light"] body [style*="background:#fff"][style*="color"],
[data-theme="light"] body [style*="background: #fff"][style*="color"] {
    color: #0f172a !important;
}

.widget,
.stat-card,
.node-card,
.auth-card {
    color: var(--text-primary);
}

.search-field:is(input, textarea, select) {
    display: block;
    width: 100%;
}

.widget *,
.stat-card *,
.node-card *,
.auth-card * {
    max-width: 100%;
}

.widget :where(p, span, div, code, b, strong, small),
.stat-card :where(p, span, div, code, b, strong, small),
.node-card :where(p, span, div, code, b, strong, small) {
    word-break: break-word;
}

@media (max-width: 1024px) {
    body [id$="Modal"] {
        padding: 8px !important;
    }

    body [id$="Modal"] > div,
    #projectOnboardingModal > div {
        width: min(96vw, 760px) !important;
        max-height: calc(100vh - 16px) !important;
        overflow: auto !important;
    }

    [style*="display:grid"][style*="repeat(4"] {
        grid-template-columns: 1fr !important;
        gap: 0.9rem !important;
    }
}

/* Live notifications (top-right) */
.fx-live-notice-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 12000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(420px, calc(100vw - 32px));
}

.fx-live-notice {
    border: 1px solid var(--border-bright);
    background: var(--bg-side);
    color: var(--text-primary);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .32);
    padding: 12px 14px;
    cursor: pointer;
}

.fx-live-notice-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
}

.fx-live-notice-msg {
    font-size: 14px;
    font-weight: 600;
    margin-top: 4px;
}

/* Reusable admin confirm/prompt modal */
.fx-adm-ui-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 13000;
    background: rgba(7, 10, 18, 0.62);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.fx-adm-ui-modal-card {
    width: min(560px, calc(100vw - 32px));
    border: 1px solid var(--border-bright);
    background: var(--bg-side);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-main);
    padding: 16px;
}

.fx-adm-ui-modal-title {
    font-size: 1.05rem;
    font-weight: 800;
}

.fx-adm-ui-modal-body {
    margin-top: 8px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.fx-adm-ui-modal-field-wrap {
    margin-top: 12px;
}

.fx-adm-ui-modal-input {
    min-height: 96px;
    resize: vertical;
}

.fx-adm-ui-modal-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.fx-admin-legal-pre {
    margin-top: 12px;
    max-height: 62vh;
    overflow: auto;
    white-space: pre-wrap;
    font-size: .86rem;
    line-height: 1.45;
    color: var(--text-primary);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-2);
}

.auth-card .search-field {
    color: var(--text-primary);
    background: var(--bg-card);
}

.fx-admin-legal-header p,
.fx-admin-legal-muted {
    color: var(--text-muted);
}

.fx-admin-legal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
}

.fx-admin-legal-card {
    min-width: 0;
}

.fx-admin-legal-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 0;
}

@media (max-width: 1100px) {
    .fx-admin-legal-grid {
        grid-template-columns: 1fr;
    }
}

/* Ticket links: only internal FluxFacile messages are linkified in JS */
.fx-adm-msg-bubble-internal a,
.fx-adm-discussion-item.is-internal a {
    color: var(--accent-light);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
}

/* Phone optimization pass */
@media (max-width: 768px) {
    .app-shell {
        min-height: 100dvh;
    }

    .sidebar {
        width: min(86vw, 320px);
        min-width: min(86vw, 320px);
        max-width: min(86vw, 320px);
        padding: 1rem 0.75rem;
    }

    .header-pro {
        padding: 0.6rem 0.75rem;
        gap: 0.6rem;
    }

    .header-pro > div {
        width: 100%;
    }

    .header-pro .search-field {
        width: 100%;
        min-width: 0;
    }

    .fx-adm-part-inline-11 {
        width: 100%;
        justify-content: space-between;
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .fx-adm-part-inline-14 {
        padding-left: 0;
        border-left: none;
    }

    .scroll-container {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.35rem;
        letter-spacing: -0.03em;
    }

    h2 {
        font-size: 1.05rem;
    }

    .widget,
    .stat-card,
    .node-card {
        padding: 0.9rem;
        border-radius: 12px;
    }

    .btn-pro {
        min-height: 42px;
        padding: 0.62rem 0.9rem;
    }

    .tab-row {
        gap: 0.6rem;
        padding-bottom: 0.2rem;
    }

    .tab-link {
        font-size: 0.86rem;
        padding: 0.72rem 0.1rem;
    }

    .enterprise-table {
        min-width: 560px;
    }

    .fx-live-notice-stack {
        left: 10px;
        right: 10px;
        top: 10px;
        max-width: none;
    }

    .auth-card {
        width: min(94vw, 420px);
        padding: 1.2rem;
        border-radius: 14px;
    }
}

@media (max-width: 560px) {
    .sidebar {
        width: 92vw;
        min-width: 92vw;
        max-width: 92vw;
    }

    .nav-item {
        padding: 0.68rem 0.72rem;
        font-size: 0.88rem;
    }

    .nav-label {
        font-size: 0.64rem;
        padding: 0 0.5rem 0.55rem;
    }

    .scroll-container {
        padding: 0.62rem;
        padding-bottom: calc(0.62rem + env(safe-area-inset-bottom));
    }

    #admin-name {
        max-width: 62vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
