/* AgentFactory Enterprise UI polish layer
   Safe additive stylesheet: no controller/model changes required. */
:root,
html[data-theme="dark"] {
    --af-bg-0: #050812;
    --af-bg-1: #0b1020;
    --af-bg-2: #111827;
    --af-surface-1: rgba(15, 23, 42, .92);
    --af-surface-2: rgba(30, 41, 59, .78);
    --af-surface-3: rgba(51, 65, 85, .58);
    --af-border: rgba(148, 163, 184, .18);
    --af-border-strong: rgba(148, 163, 184, .30);
    --af-text: #f8fafc;
    --af-text-2: #dbeafe;
    --af-muted: #94a3b8;
    --af-muted-2: #64748b;
    --af-primary: #4f8cff;
    --af-primary-2: #7c3aed;
    --af-success: #22c55e;
    --af-warning: #f59e0b;
    --af-danger: #ef4444;
    --af-info: #06b6d4;
    --af-radius-lg: 28px;
    --af-radius-md: 20px;
    --af-radius-sm: 14px;
    --af-shadow-lg: 0 26px 80px rgba(2, 6, 23, .42);
    --af-shadow-md: 0 18px 50px rgba(2, 6, 23, .30);
}

html[data-theme="light"] {
    --af-bg-0: #f6f8fc;
    --af-bg-1: #eef4ff;
    --af-bg-2: #ffffff;
    --af-surface-1: rgba(255, 255, 255, .96);
    --af-surface-2: rgba(248, 250, 252, .96);
    --af-surface-3: rgba(241, 245, 249, .90);
    --af-border: rgba(15, 23, 42, .12);
    --af-border-strong: rgba(15, 23, 42, .20);
    --af-text: #0f172a;
    --af-text-2: #1e293b;
    --af-muted: #64748b;
    --af-muted-2: #94a3b8;
    --af-shadow-lg: 0 24px 70px rgba(15, 23, 42, .10);
    --af-shadow-md: 0 16px 42px rgba(15, 23, 42, .08);
}

body.af-body {
    color: var(--af-text);
    background:
        radial-gradient(circle at 14% 0%, rgba(79, 140, 255, .18), transparent 30%),
        radial-gradient(circle at 84% 8%, rgba(124, 58, 237, .14), transparent 32%),
        linear-gradient(180deg, var(--af-bg-0), var(--af-bg-1));
}

.af-shell { min-height: 100vh; }
.af-main { min-width: 0; }

.af-sidebar {
    background: linear-gradient(180deg, rgba(2,6,23,.98), rgba(15,23,42,.96));
    border-right: 1px solid var(--af-border);
    box-shadow: 18px 0 70px rgba(2,6,23,.20);
}
html[data-theme="light"] .af-sidebar {
    background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.af-brand {
    border-bottom: 1px solid var(--af-border);
    padding-bottom: 14px;
    margin-bottom: 10px;
}
.af-brand-mark {
    background: linear-gradient(135deg, var(--af-primary), var(--af-primary-2));
    color: #fff !important;
    box-shadow: 0 12px 30px rgba(79, 140, 255, .24);
}
.af-brand-text { letter-spacing: -.02em; }
.af-nav { gap: 4px; }
.af-nav-section {
    margin: 17px 10px 7px;
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--af-muted);
}
.af-nav-link {
    border-radius: 14px;
    color: var(--af-muted);
    transition: background .18s ease, color .18s ease, transform .18s ease, border-color .18s ease;
    border: 1px solid transparent;
}
.af-nav-link:hover {
    transform: translateX(2px);
    color: var(--af-text);
    background: rgba(79, 140, 255, .12);
    border-color: rgba(79, 140, 255, .18);
}
.af-nav-link.active {
    color: #fff !important;
    background: linear-gradient(135deg, rgba(37,99,235,.95), rgba(124,58,237,.86));
    border-color: rgba(147,197,253,.45);
    box-shadow: 0 14px 34px rgba(37,99,235,.22);
}
html[data-theme="light"] .af-nav-link.active { color: #fff !important; }

.af-topbar {
    backdrop-filter: blur(18px);
    background: color-mix(in srgb, var(--af-surface-1) 90%, transparent);
    border-bottom: 1px solid var(--af-border);
    box-shadow: 0 12px 40px rgba(2,6,23,.10);
}
.af-topbar-kicker { color: var(--af-muted); font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.af-topbar-headline { color: var(--af-text); font-weight: 800; letter-spacing: -.02em; }
.af-content { padding-top: 26px; }

/* Enterprise page primitives */
.af-page-hero,
.kh-hero,
.mon-hero,
.diag-hero {
    position: relative;
    overflow: hidden;
    color: var(--af-text) !important;
    background:
        radial-gradient(circle at top left, rgba(79, 140, 255, .26), transparent 36%),
        radial-gradient(circle at bottom right, rgba(124, 58, 237, .20), transparent 40%),
        linear-gradient(135deg, color-mix(in srgb, var(--af-surface-1) 92%, #000 8%), color-mix(in srgb, var(--af-surface-2) 92%, #000 8%));
    border: 1px solid var(--af-border);
    border-radius: var(--af-radius-lg) !important;
    box-shadow: var(--af-shadow-lg);
}
.af-page-hero::after,
.kh-hero::after,
.mon-hero::after,
.diag-hero::after {
    content: "";
    position: absolute;
    inset: auto -80px -120px auto;
    width: 300px;
    height: 300px;
    background: rgba(6, 182, 212, .12);
    filter: blur(70px);
    pointer-events: none;
}

.af-card,
.kh-card,
.kh-panel,
.mon-card,
.diag-card,
.card {
    color: var(--af-text);
    background: var(--af-surface-1) !important;
    border: 1px solid var(--af-border) !important;
    border-radius: var(--af-radius-md) !important;
    box-shadow: var(--af-shadow-md);
}
.card-header,
.card-footer {
    background: var(--af-surface-2) !important;
    border-color: var(--af-border) !important;
    color: var(--af-text) !important;
}
.af-muted,
.kh-muted,
.mon-muted,
.diag-muted,
.text-muted { color: var(--af-muted) !important; }

.af-kpi-card {
    padding: 18px;
    min-height: 106px;
    background: linear-gradient(180deg, var(--af-surface-1), var(--af-surface-2));
    border: 1px solid var(--af-border);
    border-radius: var(--af-radius-md);
}
.af-kpi-label { color: var(--af-muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.af-kpi-value { color: var(--af-text); font-size: 1.9rem; font-weight: 900; letter-spacing: -.04em; }

/* Buttons */
.btn { font-weight: 750; }
.btn-primary,
.af-primary-btn {
    border: 0 !important;
    background: linear-gradient(135deg, var(--af-primary), var(--af-primary-2)) !important;
    box-shadow: 0 12px 32px rgba(79, 140, 255, .24);
}
.btn-outline-light,
.btn-outline-secondary,
.btn-outline-info,
.btn-outline-warning,
.btn-outline-danger,
.btn-outline-success,
.af-icon-btn,
.af-theme-btn,
.af-user-btn {
    border-color: var(--af-border-strong) !important;
    color: var(--af-text) !important;
    background: color-mix(in srgb, var(--af-surface-2) 74%, transparent) !important;
}
.btn-outline-light:hover,
.btn-outline-secondary:hover,
.btn-outline-info:hover,
.af-icon-btn:hover,
.af-theme-btn:hover,
.af-user-btn:hover {
    background: rgba(79, 140, 255, .16) !important;
    border-color: rgba(79, 140, 255, .38) !important;
}

/* Forms */
.form-control,
.form-select,
.input-group-text,
textarea.form-control {
    color: var(--af-text) !important;
    background-color: color-mix(in srgb, var(--af-surface-1) 92%, transparent) !important;
    border-color: var(--af-border-strong) !important;
    border-radius: 14px !important;
}
.form-control:focus,
.form-select:focus {
    border-color: rgba(79, 140, 255, .70) !important;
    box-shadow: 0 0 0 .22rem rgba(79, 140, 255, .16) !important;
}
.form-label { color: var(--af-text-2); font-weight: 750; }
.form-text { color: var(--af-muted) !important; }
.form-control::placeholder { color: var(--af-muted-2) !important; }

/* Tables */
.table { color: var(--af-text) !important; }
.table > :not(caption) > * > * {
    background: transparent !important;
    color: inherit !important;
    border-color: var(--af-border) !important;
}
.table thead th {
    color: var(--af-muted) !important;
    font-size: .76rem;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.table-hover tbody tr:hover { background: rgba(79, 140, 255, .08) !important; }

/* Source / connector cards */
.kh-source-card,
.af-source-card {
    background: linear-gradient(180deg, var(--af-surface-1), var(--af-surface-2)) !important;
    border: 1px solid var(--af-border) !important;
    border-radius: 20px !important;
    box-shadow: 0 14px 38px rgba(2,6,23,.18);
}
.kh-source-card.active,
.af-source-card.active {
    border-color: rgba(79, 140, 255, .75) !important;
    background: linear-gradient(135deg, rgba(37, 99, 235, .28), rgba(124, 58, 237, .22)) !important;
}
.kh-icon,
.af-icon-tile {
    background: linear-gradient(135deg, rgba(79, 140, 255, .22), rgba(124, 58, 237, .18)) !important;
    color: #bfdbfe !important;
}

/* Badges and status */
.badge { border-radius: 999px; padding: .46rem .66rem; font-weight: 800; }
.text-bg-success { background: rgba(34,197,94,.18) !important; color: #86efac !important; border: 1px solid rgba(34,197,94,.25); }
.text-bg-danger { background: rgba(239,68,68,.18) !important; color: #fca5a5 !important; border: 1px solid rgba(239,68,68,.25); }
.text-bg-warning { background: rgba(245,158,11,.18) !important; color: #fde68a !important; border: 1px solid rgba(245,158,11,.25); }
.text-bg-secondary { background: rgba(148,163,184,.16) !important; color: #cbd5e1 !important; border: 1px solid rgba(148,163,184,.25); }

/* Alerts / waits / modals */
.alert {
    color: var(--af-text) !important;
    background: var(--af-surface-1) !important;
    border: 1px solid var(--af-border) !important;
    border-radius: 18px !important;
}
.modal-content {
    color: var(--af-text);
    background: var(--af-surface-1);
    border: 1px solid var(--af-border);
    border-radius: 24px;
    box-shadow: var(--af-shadow-lg);
}
.af-wait-card,
.diag-wait-card,
.mon-wait-card {
    color: var(--af-text) !important;
    background:
        radial-gradient(circle at top left, rgba(79, 140, 255, .28), transparent 32%),
        linear-gradient(135deg, rgba(15,23,42,.98), rgba(30,41,59,.96)) !important;
    border: 1px solid rgba(147,197,253,.22) !important;
    border-radius: 28px !important;
    box-shadow: var(--af-shadow-lg) !important;
}

/* Empty state */
.af-empty-state {
    padding: 44px 24px;
    text-align: center;
    border: 1px dashed var(--af-border-strong);
    border-radius: 24px;
    background: color-mix(in srgb, var(--af-surface-2) 58%, transparent);
}
.af-empty-state i { font-size: 2.4rem; color: var(--af-primary); }

/* Responsive polish */
@media (max-width: 991.98px) {
    .af-content { padding: 18px 14px; }
    .af-page-hero, .kh-hero, .mon-hero, .diag-hero { border-radius: 22px !important; }
    .af-topbar { position: sticky; top: 0; z-index: 1010; }
}

/* Dialog sizing and scroll-lock are centralized in agentfactory-dialog-system.css. */
