/* ═══════════════════════════════════════════════════════════════════
   UniBot Design System — Linear/Vercel aesthetic
   One accent (indigo) + zinc neutrals. No gradients on UI elements.
   ═══════════════════════════════════════════════════════════════════ */

:root {
    /* Accent — Figma: dark green #3d5947 */
    --accent:        #3d5947;
    --accent-hover:  #2a3d30;
    --accent-subtle: rgba(61, 89, 71, 0.08);
    --accent-text:   #3d5947;
    --accent-light:  #6b8f70;

    /* Surfaces — Figma: warm beige tones */
    --surface:       #ffffff;
    --surface-2:     #f5f2f0;
    --surface-3:     #edeae7;
    --surface-dim:   #f5f7f5;

    /* Borders — Figma: warm/green-tinted */
    --border:        #d9d6d1;
    --border-strong: #c4c1bc;
    --border-accent: #d9e3db;

    /* Text — Figma */
    --text:          #1a1a1a;
    --text-2:        #2b2b2b;
    --text-3:        #737373;
    --text-muted:    #858585;

    /* Semantic */
    --success:       #10b981;
    --success-bg:    rgba(16, 185, 129, 0.08);
    --warning:       #f59e0b;
    --warning-bg:    rgba(245, 158, 11, 0.08);
    --danger:        #ef4444;
    --danger-bg:     rgba(239, 68, 68, 0.08);
    --info:          #3d5947;
    --info-bg:       rgba(61, 89, 71, 0.08);

    /* Layout */
    --sidebar-width:  240px;
    --topbar-height:  52px;
    --radius:         10px;      /* inputs, nav items, small cards */
    --radius-lg:      12px;      /* cards, panels — Figma 12px */
    --radius-xl:      16px;      /* modals, login card */
    --radius-pill:    999px;     /* buttons, badges */
    --radius-btn:     6px;       /* Figma button radius */
}

/* ── Dark Theme ────────────────────────────────────────────────── */
[data-theme="dark"] {
    --accent:        #6b9e7a;
    --accent-hover:  #7fb58d;
    --accent-subtle: rgba(107, 158, 122, 0.12);
    --accent-text:   #8bc49a;
    --accent-light:  #4a7a58;

    --surface:       #161616;
    --surface-2:     #1c1c1c;
    --surface-3:     #262626;
    --surface-dim:   #1a1a1a;

    --border:        #2e2e2e;
    --border-strong: #3a3a3a;
    --border-accent: #2a3a2e;

    --text:          #e8e8e8;
    --text-2:        #c8c8c8;
    --text-3:        #858585;
    --text-muted:    #6b6b6b;

    --success:       #34d399;
    --success-bg:    rgba(52, 211, 153, 0.12);
    --warning:       #fbbf24;
    --warning-bg:    rgba(251, 191, 36, 0.12);
    --danger:        #f87171;
    --danger-bg:     rgba(248, 113, 113, 0.12);
    --info:          #6b9e7a;
    --info-bg:       rgba(107, 158, 122, 0.12);

    color-scheme: dark;
}

/* Dark theme smooth transition */
body, .sidebar, .top-bar, .card, .modal, .flow-node,
.tester-chat-panel, .tester-chat-header, .tester-input-area,
.tester-buttons-area, .login-card, .confirm-dialog,
.flow-sidebar, .stat-card, .ub-grid, .ub-grid-filters {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* ── Dark Radzen: remap base palette to dark surfaces ──────────── */
[data-theme="dark"] {
    --rz-base-50:  #1a1a1a;
    --rz-base-100: #1c1c1c;
    --rz-base-200: #222222;
    --rz-base-300: #3a3a3a;   /* border-normal derives from this */
    --rz-base-400: #4a4a4a;
    --rz-base-500: #6b6b6b;
    --rz-base-600: #858585;
    --rz-base-700: #a0a0a0;
    --rz-base-800: #c8c8c8;
    --rz-base-900: #e8e8e8;
    --rz-on-base:  #e8e8e8;
    --rz-primary:       var(--accent);
    --rz-primary-light: var(--accent-hover);
    --rz-primary-lighter: var(--accent-subtle);
    --rz-primary-dark:  var(--accent);
    --rz-on-primary: #ffffff;
}

/* Dark Radzen inputs (standalone, outside FormField) */
[data-theme="dark"] :not(.rz-form-field-content) > .rz-text-box,
[data-theme="dark"] :not(.rz-form-field-content) > .rz-textbox,
[data-theme="dark"] :not(.rz-form-field-content) > .rz-textarea,
[data-theme="dark"] :not(.rz-form-field-content) > .rz-dropdown {
    background: var(--surface-3) !important;
    color: var(--text) !important;
    border-color: var(--border-strong) !important;
}

[data-theme="dark"] :not(.rz-form-field-content) > .rz-text-box:focus,
[data-theme="dark"] :not(.rz-form-field-content) > .rz-textarea:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(107, 158, 122, 0.2) !important;
}

[data-theme="dark"] .rz-dropdown-panel,
[data-theme="dark"] .rz-dropdown-items-wrapper {
    background: var(--surface-2) !important;
    border-color: var(--border) !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4) !important;
}

[data-theme="dark"] .rz-dropdown-item:hover {
    background: var(--surface-3) !important;
}

[data-theme="dark"] .rz-grid-table th {
    background: var(--surface-3) !important;
    color: var(--text-3) !important;
    border-bottom-color: var(--border) !important;
}

[data-theme="dark"] .rz-grid-table td {
    border-bottom-color: var(--border) !important;
    color: var(--text) !important;
}

[data-theme="dark"] .rz-data-row td {
    background: var(--surface) !important;
}

[data-theme="dark"] .rz-data-row:hover td {
    background: var(--surface-3) !important;
}

/* Radzen filter row in dark mode */
[data-theme="dark"] .rz-grid-table .rz-filter-row td,
[data-theme="dark"] .rz-grid-table .rz-filter-row th {
    background: var(--surface-2) !important;
}

[data-theme="dark"] .rz-grid-table .rz-filter-row input,
[data-theme="dark"] .rz-grid-table .rz-filter-row .rz-textbox,
[data-theme="dark"] .rz-grid-table .rz-filter-row .rz-dropdown {
    background: var(--surface-3) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* Radzen pager dark mode */
[data-theme="dark"] .rz-pager {
    background: var(--surface-2) !important;
    border-top-color: var(--border) !important;
}

[data-theme="dark"] .rz-pager .rz-pager-page,
[data-theme="dark"] .rz-pager button {
    color: var(--text-2) !important;
}

/* Radzen dropdowns inside grid dark mode */
[data-theme="dark"] .rz-grid-table .rz-dropdown,
[data-theme="dark"] .rz-grid-table .rz-dropdown .rz-inputtext {
    background: var(--surface-2) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

[data-theme="dark"] .rz-messages .rz-message {
    background: var(--surface-3) !important;
    color: var(--text) !important;
}

/* Dark modal overlay */
[data-theme="dark"] .modal-overlay,
[data-theme="dark"] .confirm-overlay,
[data-theme="dark"] .sidebar-overlay {
    background: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .modal,
[data-theme="dark"] .confirm-dialog {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* Dark flow node */
[data-theme="dark"] .flow-node {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .flow-node:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .flow-node.selected {
    box-shadow: 0 0 0 3px rgba(107, 158, 122, 0.35);
}

/* Dark login card */
[data-theme="dark"] .login-card {
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.3);
}

/* Dark template cards — more visible on dark background */
[data-theme="dark"] .card.template-card {
    background: var(--surface-2);
    border-color: var(--border-strong);
}

[data-theme="dark"] .card.template-card:hover {
    background: var(--surface-3);
    border-color: var(--accent-light);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Template card title & description legibility */
[data-theme="dark"] .card.template-card h4 {
    color: var(--text);
}

[data-theme="dark"] .card.template-card p {
    color: var(--text-3);
}

/* Dark scrollbar */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--surface-2);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--text-3);
}

/* Theme toggle button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.theme-toggle:hover {
    background: var(--surface-3);
    color: var(--text);
}

.theme-toggle svg {
    width: 16px;
    height: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--surface-2);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ── App shell ───────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 200;
    transition: transform 0.2s ease;
    overflow: hidden;
}

.sidebar-logo {
    height: var(--topbar-height);
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-logo-icon {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.sidebar-logo h1 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.nav-section { margin-bottom: 20px; }

.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    padding: 0 10px;
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-2);
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.1s, color 0.1s;
    margin-bottom: 1px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    line-height: 1.4;
}

.nav-item:hover {
    background: var(--surface-3);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 600;
}

.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }

/* ── Main content ───────────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ── Top bar ────────────────────────────────────────────────────── */
.top-bar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Hamburger — mobile only */
.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: none;
    cursor: pointer;
    color: var(--text-2);
    transition: background 0.1s;
}
.hamburger:hover { background: var(--surface-3); }

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
    animation: fadeIn 0.15s ease;
}

/* ── Page content ───────────────────────────────────────────────── */
.page-content {
    padding: 24px;
    flex: 1;
}

/* ── Page header ────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.card--clickable {
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.card--clickable:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.1s, opacity 0.1s, box-shadow 0.1s;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-2);
}
.btn-outline:hover { background: var(--surface-3); color: var(--text); }

.btn-ghost {
    background: transparent;
    color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}
.btn-danger-outline:hover { background: var(--danger-bg); }

.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-sm { padding: 6px 14px; font-size: 12.5px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-neutral { background: var(--surface-3);  color: var(--text-2); }

/* ── Stats grid ─────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    padding: 20px 22px;
}

.stat-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-3);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 4px;
}

/* ── Loading ────────────────────────────────────────────────────── */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 12px;
    background: var(--surface-2);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loading-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 160px;
    color: var(--text-3);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Radzen busy-spinner fix (Material Icons fallback) ─────────── */
/* When Material Icons font fails to load, Radzen shows raw text
   "refresh" spinning instead of icon glyph. Replace with CSS spinner. */
.rzi-circle-o-notch,
.rz-button .rzi-circle-o-notch {
    font-size: 0 !important;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.7s linear infinite;
}
.rzi-circle-o-notch::before {
    content: "" !important;          /* suppress "refresh" text     */
}

/* ── Empty state ────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--text-3);
    text-align: center;
    gap: 12px;
}

.empty-state-icon {
    font-size: 2.5rem;
    line-height: 1;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-2);
}

.empty-state-text {
    font-size: 13px;
    max-width: 300px;
}

/* ── Login ──────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    padding: 24px;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    padding: 36px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 32px rgba(0,0,0,0.08);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 28px;
}

.login-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.login-card h2 {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
    color: var(--text);
    letter-spacing: -0.01em;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-3);
    margin-bottom: 24px;
    font-size: 13.5px;
}

/* ── Field error ────────────────────────────────────────────────── */
.field-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

/* ── Divider ────────────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* ── Section label ──────────────────────────────────────────────── */
.section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 8px;
}

/* ═══════════════════════════════════════════════════════════════════
   FLOW EDITOR
   ═══════════════════════════════════════════════════════════════════ */

.flow-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.flow-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.flow-topbar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.flow-editor {
    display: flex;
    height: calc(100vh - 160px);
    min-height: 400px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--surface);
}

.flow-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.flow-sidebar-header {
    padding: 12px 14px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.flow-sidebar-body {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
}

.node-palette-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    transition: border-color 0.1s, color 0.1s, background 0.1s;
    user-select: none;
}

.node-palette-item:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

.node-palette-icon {
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}

/* Canvas */
.flow-canvas {
    flex: 1;
    background: var(--surface-2);
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.flow-canvas-inner {
    padding: 20px;
    min-height: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-content: flex-start;
}

/* SVG Flow Editor container */
.flow-canvas-svg-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Node cards on canvas */
.flow-node {
    width: 190px;
    padding: 14px;
    border-radius: var(--radius-xl);
    border: 2px solid transparent;
    background: var(--surface);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    transition: box-shadow 0.15s, transform 0.1s;
    position: relative;
    user-select: none;
}

.flow-node:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-1px);
}

.flow-node.selected {
    box-shadow: 0 0 0 3px rgba(61,89,71,0.25);
}

.flow-node-header {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
}

.flow-node-icon {
    font-size: 15px;
    line-height: 1;
}

.flow-node-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-node-preview {
    font-size: 11.5px;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.flow-node-meta {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 4px;
}

.flow-node-connections {
    font-size: 11px;
    color: var(--accent);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.flow-node-edit-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-3);
    opacity: 0;
    transition: opacity 0.1s;
    font-size: 12px;
}

.flow-node:hover .flow-node-edit-btn { opacity: 1; }

.flow-canvas-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: var(--text-3);
    text-align: center;
    gap: 12px;
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════
   MODAL / OVERLAY
   ═══════════════════════════════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.15s ease;
}

/* ── Gen-chip: toggle chips for AI generation form ── */
.gen-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-2);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.gen-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.gen-chip--active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.gen-chip--active:hover {
    opacity: 0.85;
    color: #fff;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: slideUp 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
}

.modal-header-info {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.modal-node-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.modal-node-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.modal-node-type {
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
}

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-pill);
    border: none;
    background: var(--surface-3);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: background 0.1s;
    line-height: 1;
}
.modal-close:hover { background: var(--border); }

.modal-body {
    padding: 18px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}

/* Confirm-style modal (delete, etc.) */
.modal-sm { max-width: 380px; }

/* ── Modal sub-sections ─────────────────────────────────────────── */
.modal-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 4px;
}

/* Option item (menu/condition) */
.option-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface-2);
}

.option-item-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ═══════════════════════════════════════════════════════════════════
   CONFIRMATION MODAL (delete)
   ═══════════════════════════════════════════════════════════════════ */

.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.15s ease;
}

.confirm-dialog {
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    padding: 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: slideUp 0.2s ease;
}

.confirm-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.confirm-text {
    font-size: 13.5px;
    color: var(--text-2);
    margin-bottom: 20px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════ */

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════════════════════════════════════════════════════════
   RADZEN OVERRIDES — align with design system
   ═══════════════════════════════════════════════════════════════════ */

/* Override Radzen primary color variables */
:root {
    --rz-primary:          var(--accent);
    --rz-primary-light:    var(--accent-subtle);
    --rz-primary-dark:     var(--accent-hover);
    --rz-border-radius:    var(--radius);    /* base radius for Radzen internals */
}

/* Standalone Radzen inputs — pill-shaped (only outside RadzenFormField) */
:not(.rz-form-field-content) > .rz-text-box,
:not(.rz-form-field-content) > .rz-textbox,
:not(.rz-form-field-content) > .rz-numeric input,
:not(.rz-form-field-content) > .rz-password input {
    border-radius: var(--radius-pill) !important;
    border-color: var(--border) !important;
}

/* All Radzen inputs — consistent font & padding */
.rz-text-box,
.rz-textbox,
.rz-numeric input,
.rz-password input {
    font-size: 13.5px !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
}

/* Inside RadzenFormField — no own border, container handles it */
.rz-form-field-content .rz-text-box,
.rz-form-field-content .rz-textbox,
.rz-form-field-content .rz-numeric input,
.rz-form-field-content .rz-password input,
.rz-form-field-content .rz-dropdown {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

/* FormField container — normal rounded, themed background & border */
.rz-form-field .rz-form-field-content {
    border-radius: var(--radius) !important;
    background: var(--surface) !important;
    border-color: var(--border) !important;
}

[data-theme="dark"] .rz-form-field .rz-form-field-content {
    background: var(--surface-3) !important;
    border-color: var(--border-strong) !important;
}

[data-theme="dark"] .rz-form-field:hover .rz-form-field-content {
    border-color: var(--accent-light) !important;
}

[data-theme="dark"] .rz-form-field.rz-state-focused .rz-form-field-content {
    border-color: var(--accent) !important;
}

/* FormField floating label — match background for gap */
[data-theme="dark"] .rz-form-field-label {
    color: var(--text-3) !important;
}

/* TextArea stays rectangular — pill looks bad for multiline */
.rz-textarea {
    border-radius: var(--radius-lg) !important;
    border-color: var(--border) !important;
    font-size: 13.5px !important;
}

/* FormField with textarea — same radius */
.rz-form-field:has(.rz-textarea) .rz-form-field-content {
    border-radius: var(--radius) !important;
}

/* Standalone dropdown — pill */
:not(.rz-form-field-content) > .rz-dropdown {
    border-radius: var(--radius-pill) !important;
    border-color: var(--border) !important;
}

/* All dropdowns — consistent font */
.rz-dropdown {
    font-size: 13.5px !important;
}

/* Dropdown popup list — rounded, not pill */
.rz-dropdown-panel,
.rz-dropdown-items-wrapper {
    border-radius: var(--radius-lg) !important;
    border-color: var(--border) !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12) !important;
    overflow: hidden;
}

.rz-dropdown-item {
    border-radius: 0 !important;
    font-size: 13.5px !important;
}

.rz-text-box:focus,
.rz-textarea:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(61,89,71,0.12) !important;
}

/* Radzen Button pill */
.rz-button {
    border-radius: var(--radius-pill) !important;
}

/* Standalone Radzen NumericInput wrapper */
:not(.rz-form-field-content) > .rz-numeric {
    border-radius: var(--radius-pill) !important;
}

/* Radzen FormField label */
.rz-form-field > label,
.rz-form-field-label {
    font-size: 12.5px !important;
    font-weight: 500 !important;
    color: var(--text-2) !important;
}

/* Radzen DataGrid */
.rz-grid-table th {
    background: var(--surface-2) !important;
    border-bottom: 1px solid var(--border) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: var(--text-3) !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rz-grid-table td {
    border-bottom: 1px solid var(--border) !important;
    font-size: 13.5px !important;
}

.rz-data-row:hover td {
    background: var(--surface-2) !important;
}

/* Radzen Alert */
.rz-messages .rz-message {
    border-radius: var(--radius) !important;
    font-size: 13px !important;
}

/* Radzen Button overrides */
.rz-button.rz-primary {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
}
.rz-button.rz-primary:hover:not([disabled]) {
    background: var(--accent-hover) !important;
}

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

/* Tablet */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile */
@media (max-width: 768px) {
    /* Sidebar hidden off-screen */
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.sidebar--open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }

    .sidebar-overlay.sidebar-overlay--open {
        display: block;
    }

    /* No left margin on mobile */
    .main-content {
        margin-left: 0;
    }

    /* Hamburger visible */
    .hamburger {
        display: flex;
    }

    /* Tighter page content */
    .page-content {
        padding: 16px;
    }

    .top-bar {
        padding: 0 16px;
    }

    /* Stats full-width on mobile */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    /* Flow editor: stack on mobile */
    .flow-editor {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 200px);
    }

    .flow-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .flow-sidebar-body {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px;
        max-height: 140px;
        overflow-y: auto;
    }

    .node-palette-item {
        margin-bottom: 0;
        padding: 6px 9px;
        font-size: 12px;
    }

    .flow-canvas {
        min-height: 400px;
        /* Prevent iOS rubber-band scroll on the canvas area */
        touch-action: none;
        -webkit-overflow-scrolling: auto;
    }

    /* SVG container takes full height on mobile */
    .flow-canvas-svg-container {
        min-height: 400px;
    }

    /* Hide minimap on mobile — takes too much space */
    .fe-minimap {
        display: none !important;
    }

    /* Larger zoom controls for touch */
    .fe-zoom-controls button {
        width: 44px !important;
        height: 44px !important;
        font-size: 20px !important;
    }

    .flow-node {
        width: 160px;
    }

    /* Modal full-width on mobile — bottom sheet */
    .modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    /* Login card tighter */
    .login-card {
        padding: 28px 24px;
    }

    /* Flow topbar wrap */
    .flow-topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .flow-topbar-right {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Bot Logs page ──────────────────────────────────────────────────────── */

.logs-page {
    max-width: 1200px;
}

.logs-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    align-items: start;
}

/* Users list panel */
.logs-users-panel {
    position: sticky;
    top: calc(var(--topbar-height) + 16px);
    max-height: calc(100vh - var(--topbar-height) - 60px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.log-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    color: var(--text);
}

.log-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.log-pager-info {
    font-size: 0.8rem;
    color: var(--text-2);
    padding: 0 4px;
    white-space: nowrap;
}

.log-user-item:hover {
    background: var(--surface-3);
}

.log-user-item--active {
    background: var(--accent-subtle);
    border-right: 3px solid var(--accent);
}

.log-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Timeline */
.logs-timeline {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.logs-date-group {
    margin-bottom: 24px;
}

.logs-date-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    padding: 8px 0 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.log-entry {
    display: flex;
    gap: 12px;
    padding: 8px 0;
}

.log-entry-time {
    width: 68px;
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--text-3);
    padding-top: 3px;
    font-variant-numeric: tabular-nums;
}

.log-entry-body {
    flex: 1;
    min-width: 0;
}

.log-entry-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.log-entry-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
}

.log-badge--user  { background: rgba(16,185,129,0.12); color: #059669; }
.log-badge--bot   { background: rgba(61,89,71,0.12);  color: var(--accent); }
.log-badge--node  { background: var(--surface-3);       color: var(--text-2); }
.log-badge--error { background: rgba(239,68,68,0.12);  color: var(--danger); }

.log-entry-field {
    display: flex;
    gap: 6px;
    font-size: 0.83rem;
    color: var(--text-2);
    margin-top: 3px;
    line-break: anywhere;
}

.log-entry-field--error .log-field-value {
    color: var(--danger);
}

.log-field-label {
    font-weight: 600;
    color: var(--text-3);
    flex-shrink: 0;
}

/* Left border color by type */
.log-entry--user  { border-left: 3px solid #10b981; padding-left: 10px; }
.log-entry--bot   { border-left: 3px solid var(--accent); padding-left: 10px; }
.log-entry--node  { border-left: 3px solid var(--border-strong); padding-left: 10px; }
.log-entry--error { border-left: 3px solid var(--danger); padding-left: 10px; }

@media (max-width: 860px) {
    .logs-layout {
        grid-template-columns: 1fr;
    }

    .logs-users-panel {
        position: static;
        max-height: 280px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   Bot Flow Tester — Chat Simulator
   ═══════════════════════════════════════════════════════════════════ */

.tester-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    height: calc(100vh - 80px);
    padding: 16px 20px;
}

/* ── Chat panel ─────────────────────────────────────────────────── */

.tester-chat-panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

.tester-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.tester-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tester-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface-2);
}

/* ── Messages ───────────────────────────────────────────────────── */

.tester-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

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

.tester-msg-bot {
    align-self: flex-start;
    align-items: flex-start;
}

.tester-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
}

.tester-msg-bubble-user {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.tester-msg-bubble-bot {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.tester-msg-time {
    font-size: 0.65rem;
    color: var(--text-3);
    margin-top: 2px;
    padding: 0 4px;
}

/* ── Status badge ───────────────────────────────────────────────── */

.tester-status-badge {
    align-self: center;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: var(--success-bg);
    color: var(--success);
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 8px;
}

/* ── Buttons area ───────────────────────────────────────────────── */

.tester-buttons-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.tester-btn {
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.tester-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

.tester-btn-option {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: transparent;
}

.tester-btn-option:hover {
    background: var(--accent);
    color: #fff;
}

.tester-btn-back {
    color: var(--text-3);
    border-color: var(--border);
    background: var(--surface);
}

.tester-btn-back:hover {
    color: var(--text);
    background: var(--surface-3);
}

/* ── Input area ─────────────────────────────────────────────────── */

.tester-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.tester-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.tester-input:focus {
    border-color: var(--accent);
}

.tester-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tester-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.tester-send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.tester-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Settings select ─────────────────────────────────────────────── */

.tester-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
    cursor: pointer;
    appearance: auto;
}

.tester-select:focus {
    border-color: var(--accent);
}

/* ── Info sidebar ───────────────────────────────────────────────── */

.tester-info-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
}

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .tester-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .tester-chat-panel {
        max-width: 100%;
        height: calc(100vh - 200px);
        min-height: 400px;
    }

    .tester-info-panel {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }

    .tester-info-panel .card {
        flex: 1;
        min-width: 200px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   RadzenDataGrid — Minimal Design System
   ═══════════════════════════════════════════════════════════════════ */

/* ── Grid container ─────────────────────────────────────────────── */
.ub-grid {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.ub-grid .rz-datatable-thead > tr > th {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-3);
    padding: 10px 12px;
}

.ub-grid .rz-datatable-tbody > tr > td {
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    vertical-align: middle;
}

.ub-grid .rz-datatable-tbody > tr:last-child > td {
    border-bottom: none;
}

.ub-grid .rz-datatable-tbody > tr:hover > td {
    background: var(--accent-subtle);
}

.ub-grid .rz-pager {
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-2);
}

/* ── Filters bar ────────────────────────────────────────────────── */
.ub-grid-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

/* ── Bulk-actions bar ───────────────────────────────────────────── */
.ub-bulk-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--accent-subtle);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
}

/* ── Utility classes ────────────────────────────────────────────── */
.ub-mono {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 12px;
}

.ub-text-muted {
    color: var(--text-3);
}

.ub-link-accent {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.ub-link-accent:hover {
    text-decoration: underline;
}

/* ── Stat badges (logs page) ────────────────────────────────────── */
.ub-stat-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-2);
}
.ub-stat-badge--accent {
    background: var(--accent-subtle);
    color: var(--accent);
}

/* ── Log level badges ───────────────────────────────────────────── */
.ub-level-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

/* ── Log detail panel ───────────────────────────────────────────── */
.ub-log-detail {
    padding: 16px;
    background: var(--surface-2);
    border-radius: var(--radius);
}

.ub-log-pre {
    margin-top: 6px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}

.ub-log-pre--err {
    border-color: rgba(220, 38, 38, 0.2);
    background: rgba(220, 38, 38, 0.03);
}

.ub-log-msg {
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Responsive column hiding ───────────────────────────────────── */
@media (max-width: 640px) {
    .ub-col-hide-sm { display: none !important; }
}

@media (max-width: 900px) {
    .ub-col-hide-md { display: none !important; }
}

@media (max-width: 1200px) {
    .ub-col-hide-lg { display: none !important; }
}

/* ── Filters responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
    .ub-grid-filters {
        flex-direction: column;
    }
    .ub-grid-filters > * {
        width: 100% !important;
        min-width: unset !important;
        flex: unset !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════════════ */

.dash-bot-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.1s;
    border: 1px solid transparent;
}

.dash-bot-row:hover {
    background: var(--surface-2);
    border-color: var(--border);
}

.dash-bot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dash-messenger-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-2);
}

/* Dashboard responsive */
@media (max-width: 1024px) {
    .stats-grid[style*="repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    div[style*="grid-template-columns:1fr 320px"] {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   ONBOARDING TOUR
   ═══════════════════════════════════════════════════════════════════ */

.ob-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.55);
    transition: clip-path 0.3s ease;
    pointer-events: auto;
}

.ob-highlighted {
    position: relative;
    z-index: 9001;
    outline: 3px solid var(--accent) !important;
    outline-offset: 4px;
    border-radius: var(--radius) !important;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.001);
}

.ob-tooltip {
    position: fixed;
    z-index: 9002;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    width: 320px;
    max-width: calc(100vw - 24px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    display: none;
    animation: slideUp 0.2s ease;
}

.ob-tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ob-tooltip-counter {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-subtle);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}

.ob-tooltip-close {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--surface-3);
    color: var(--text-3);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
}

.ob-tooltip-close:hover {
    background: var(--border);
    color: var(--text);
}

.ob-tooltip-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.ob-tooltip-text {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.5;
    margin-bottom: 14px;
}

.ob-tooltip-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ob-btn {
    padding: 7px 16px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.1s;
}

.ob-btn-primary {
    background: var(--accent);
    color: white;
}

.ob-btn-primary:hover {
    background: var(--accent-hover);
}

.ob-btn-ghost {
    background: transparent;
    color: var(--text-2);
}

.ob-btn-ghost:hover {
    background: var(--surface-3);
}

/* ═══════════════════════════════════════════════════════════════════
   SUPPORT WIDGET
   ═══════════════════════════════════════════════════════════════════ */

.sw-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 800;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s, box-shadow 0.15s;
    border: none;
}

.sw-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.sw-fab--hidden { display: none; }

.sw-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 801;
    width: 360px;
    max-width: calc(100vw - 24px);
    max-height: 520px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.2s ease;
}

.sw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sw-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--surface-3);
    color: var(--text-2);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sw-close:hover { background: var(--border); }

.sw-body {
    flex: 1;
    overflow-y: auto;
}

.sw-welcome {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.sw-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 13px;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
}

.sw-input:focus { border-color: var(--accent); }

.sw-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 13px;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    resize: vertical;
    font-family: inherit;
}

.sw-textarea:focus { border-color: var(--accent); }

.sw-faq-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    font-size: 12.5px;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.1s;
}

.sw-faq-item:hover {
    background: var(--surface-2);
    color: var(--accent);
}

@media (max-width: 480px) {
    .sw-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }
}

/* ── Organization members ─────────────────────────────────────── */
.org-member-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.org-member-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-subtle);
}
.org-member-card.is-owner {
    background: var(--accent-subtle);
    border-color: var(--accent);
}

.org-member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
}
.org-member-card.is-owner .org-member-avatar {
    background: var(--accent);
    color: white;
}

.org-member-info {
    flex: 1;
    min-width: 0;
}
.org-member-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    line-height: 1.3;
}
.org-member-login {
    font-size: 12.5px;
    color: var(--text-3);
    margin-top: 1px;
}
.org-member-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.org-member-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
    padding-top: 2px;
}

/* Owner section separator */
.org-section-label {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-3);
    margin: 4px 0 8px;
    padding-left: 4px;
}

@media (max-width: 600px) {
    .org-member-card {
        flex-direction: column;
        gap: 10px;
    }
    .org-member-actions {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   Radzen Dialogs — Dark Theme Fix
   Form fields were invisible (dark inputs on dark dialog background).
   ═══════════════════════════════════════════════════════════════════ */

/* Dialog container — slightly lighter than page background */
[data-theme="dark"] .rz-dialog {
    background: var(--surface-2) !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5) !important;
}

/* Dialog title bar */
[data-theme="dark"] .rz-dialog-titlebar {
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
    color: var(--text) !important;
    padding: 16px 20px !important;
}

[data-theme="dark"] .rz-dialog-title {
    color: var(--text) !important;
    font-weight: 600 !important;
}

/* Dialog close button */
[data-theme="dark"] .rz-dialog-titlebar-close {
    color: var(--text-3) !important;
}
[data-theme="dark"] .rz-dialog-titlebar-close:hover {
    color: var(--text) !important;
    background: var(--surface-3) !important;
    border-radius: var(--radius) !important;
}

/* Dialog content area */
[data-theme="dark"] .rz-dialog-content {
    background: var(--surface-2) !important;
    color: var(--text) !important;
    padding: 20px !important;
}

/* Form fields inside dialogs — contrasting background */
[data-theme="dark"] .rz-dialog .rz-form-field .rz-form-field-content {
    background: var(--surface) !important;
    border: 1px solid var(--border-strong) !important;
}

[data-theme="dark"] .rz-dialog .rz-form-field:hover .rz-form-field-content {
    border-color: var(--accent-light) !important;
}

[data-theme="dark"] .rz-dialog .rz-form-field.rz-state-focused .rz-form-field-content {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--accent-subtle) !important;
}

/* Dialog form field labels */
[data-theme="dark"] .rz-dialog .rz-form-field-label {
    color: var(--text-3) !important;
}

[data-theme="dark"] .rz-dialog .rz-form-field.rz-state-focused .rz-form-field-label {
    color: var(--accent-text) !important;
}

/* Inputs & textareas inside dialog — text contrast */
[data-theme="dark"] .rz-dialog .rz-textbox,
[data-theme="dark"] .rz-dialog .rz-text-box,
[data-theme="dark"] .rz-dialog .rz-textarea,
[data-theme="dark"] .rz-dialog .rz-numeric input,
[data-theme="dark"] .rz-dialog .rz-dropdown {
    color: var(--text) !important;
}

[data-theme="dark"] .rz-dialog .rz-textbox::placeholder,
[data-theme="dark"] .rz-dialog .rz-text-box::placeholder,
[data-theme="dark"] .rz-dialog .rz-textarea::placeholder {
    color: var(--text-muted) !important;
}

/* Dialog overlay */
[data-theme="dark"] .rz-dialog-mask {
    background: rgba(0, 0, 0, 0.65) !important;
}

/* Light theme dialog — ensure clean look too */
.rz-dialog {
    border-radius: var(--radius-lg) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12) !important;
}

.rz-dialog-titlebar {
    padding: 16px 20px !important;
}

.rz-dialog-content {
    padding: 20px !important;
}

/* ── Radzen Confirm Dialog — Dark ──────────────────────────────── */
[data-theme="dark"] .rz-confirm-dialog {
    background: var(--surface-2) !important;
    border: 1px solid var(--border-strong) !important;
}

[data-theme="dark"] .rz-confirm-dialog .rz-dialog-content {
    color: var(--text-2) !important;
}

/* ── Radzen Buttons inside Dialogs — better visibility ─────────── */
[data-theme="dark"] .rz-dialog .rz-button.rz-light {
    background: var(--surface-3) !important;
    color: var(--text-2) !important;
    border: 1px solid var(--border-strong) !important;
}

[data-theme="dark"] .rz-dialog .rz-button.rz-light:hover {
    background: var(--border-strong) !important;
    color: var(--text) !important;
}
