/* ReachLane design system */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700&display=swap');

:root {
    --rl-font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --rl-bg: #f4f6fb;
    --rl-surface: #ffffff;
    --rl-border: #e2e8f0;
    --rl-text: #0f172a;
    --rl-text-muted: #64748b;
    --rl-primary: #4f46e5;
    --rl-primary-hover: #4338ca;
    --rl-primary-soft: #eef2ff;
    --rl-accent: #0ea5e9;
    --rl-success: #059669;
    --rl-success-soft: #ecfdf5;
    --rl-danger: #dc2626;
    --rl-danger-soft: #fef2f2;
    --rl-warning: #d97706;
    --rl-warning-soft: #fffbeb;
    --rl-sidebar: #0f172a;
    --rl-sidebar-hover: rgba(255, 255, 255, 0.08);
    --rl-sidebar-active: rgba(99, 102, 241, 0.22);
    --rl-sidebar-gradient: linear-gradient(180deg, #111827 0%, #1e1b4b 55%, #312e81 100%);
    --rl-sidebar-elevated: #1e1b4b;
    --rl-brand-mark-gradient: linear-gradient(135deg, #818cf8 0%, #6366f1 50%, #4f46e5 100%);
    --rl-avatar-gradient: linear-gradient(135deg, #6366f1, #312e81);
    --rl-hero-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
    --rl-radius: 12px;
    --rl-radius-sm: 8px;
    --rl-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
    --rl-shadow-lg: 0 4px 6px rgba(15, 23, 42, 0.04), 0 20px 40px rgba(15, 23, 42, 0.08);
    --rl-transition: 0.18s ease;
}

/* User-selectable color schemes (Account → Appearance) */
html[data-rl-theme="teal"] {
    --rl-bg: #f3f7f8;
    --rl-border: #d7e2e6;
    --rl-primary: #0d9488;
    --rl-primary-hover: #0f766e;
    --rl-primary-soft: #ccfbf1;
    --rl-accent: #0284c7;
    --rl-sidebar: #0b1f1e;
    --rl-sidebar-active: rgba(45, 212, 191, 0.18);
    --rl-sidebar-gradient: linear-gradient(180deg, #0b1f1e 0%, #134e4a 55%, #0f766e 100%);
    --rl-sidebar-elevated: #134e4a;
    --rl-brand-mark-gradient: linear-gradient(135deg, #5eead4 0%, #14b8a6 50%, #0d9488 100%);
    --rl-avatar-gradient: linear-gradient(135deg, #14b8a6, #0f766e);
    --rl-hero-gradient: linear-gradient(135deg, #0b1f1e 0%, #134e4a 50%, #0f766e 100%);
}

html[data-rl-theme="graphite"] {
    --rl-bg: #f4f4f5;
    --rl-border: #e4e4e7;
    --rl-primary: #65a30d;
    --rl-primary-hover: #4d7c0f;
    --rl-primary-soft: #ecfccb;
    --rl-accent: #a3e635;
    --rl-sidebar: #18181b;
    --rl-sidebar-active: rgba(163, 230, 53, 0.2);
    --rl-sidebar-gradient: linear-gradient(180deg, #09090b 0%, #18181b 55%, #27272a 100%);
    --rl-sidebar-elevated: #27272a;
    --rl-brand-mark-gradient: linear-gradient(135deg, #bef264 0%, #84cc16 50%, #65a30d 100%);
    --rl-avatar-gradient: linear-gradient(135deg, #84cc16, #3f6212);
    --rl-hero-gradient: linear-gradient(135deg, #09090b 0%, #18181b 50%, #3f6212 100%);
}

html[data-rl-theme="coral"] {
    --rl-bg: #f7f5f2;
    --rl-border: #e7e0d8;
    --rl-primary: #e11d48;
    --rl-primary-hover: #be123c;
    --rl-primary-soft: #ffe4e6;
    --rl-accent: #0ea5e9;
    --rl-sidebar: #0f172a;
    --rl-sidebar-active: rgba(244, 63, 94, 0.22);
    --rl-sidebar-gradient: linear-gradient(180deg, #0f172a 0%, #1e293b 55%, #881337 100%);
    --rl-sidebar-elevated: #1e293b;
    --rl-brand-mark-gradient: linear-gradient(135deg, #fb7185 0%, #f43f5e 50%, #e11d48 100%);
    --rl-avatar-gradient: linear-gradient(135deg, #f43f5e, #9f1239);
    --rl-hero-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #9f1239 100%);
}

html[data-rl-theme="indigo"],
html:not([data-rl-theme]) {
    /* default tokens already on :root */
}

html, body {
    font-family: var(--rl-font);
    background: var(--rl-bg);
    color: var(--rl-text);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--rl-primary);
    text-decoration: none;
    transition: color var(--rl-transition);
}

a:hover {
    color: var(--rl-primary-hover);
}

.btn-link {
    color: var(--rl-primary);
}

.btn {
    border-radius: var(--rl-radius-sm);
    font-weight: 500;
    transition: all var(--rl-transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--rl-primary) 0%, var(--rl-primary-hover) 100%);
    border: none;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--rl-primary) 35%, transparent);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--rl-primary-hover) 0%, var(--rl-primary) 100%);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--rl-primary) 40%, transparent);
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--rl-primary);
    border-color: #c7d2fe;
}

.btn-outline-primary:hover {
    background: var(--rl-primary-soft);
    border-color: var(--rl-primary);
    color: var(--rl-primary-hover);
}

.btn-outline-secondary {
    border-color: var(--rl-border);
    color: var(--rl-text-muted);
}

.btn-outline-secondary:hover {
    background: var(--rl-bg);
    border-color: #cbd5e1;
    color: var(--rl-text);
}

.btn-sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.8125rem;
}

.btn:focus, .btn:active:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.content {
    padding-top: 1.5rem;
    padding-bottom: 2.5rem;
    max-width: none;
    width: 100%;
}

/* Cards */
.card {
    border: 1px solid var(--rl-border);
    border-radius: var(--rl-radius);
    box-shadow: var(--rl-shadow);
    background: var(--rl-surface);
    transition: box-shadow var(--rl-transition), transform var(--rl-transition);
}

.card:hover {
    box-shadow: var(--rl-shadow-lg);
}

.card-body {
    padding: 1.25rem 1.35rem;
}

.card-title {
    font-weight: 600;
    color: var(--rl-text);
}

/* Forms */
.form-control, .form-select {
    border-radius: var(--rl-radius-sm);
    border-color: var(--rl-border);
    padding: 0.55rem 0.85rem;
    transition: border-color var(--rl-transition), box-shadow var(--rl-transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--rl-primary);
}

.form-label {
    font-weight: 500;
    color: var(--rl-text);
    font-size: 0.875rem;
}

/* Tables */
.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--rl-text-muted);
    border-bottom-width: 1px;
    padding: 0.75rem 1rem;
    background: #f8fafc;
}

.table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-color: var(--rl-border);
}

.table-hover tbody tr:hover {
    background: #f8fafc;
}

.table-responsive {
    border-radius: var(--rl-radius);
    border: 1px solid var(--rl-border);
    background: var(--rl-surface);
    box-shadow: var(--rl-shadow);
}

/* Message log: fixed-height body scroll, sticky header */
.rl-msg-table-scroll {
    max-height: min(60vh, 560px);
    overflow: auto;
}

.rl-msg-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--rl-surface, #fff);
    box-shadow: inset 0 -1px 0 var(--rl-border, #dee2e6);
}

/* Alerts */
.alert {
    border-radius: var(--rl-radius-sm);
    border: none;
    font-size: 0.875rem;
}

.alert-success {
    background: var(--rl-success-soft);
    color: #065f46;
}

.alert-danger {
    background: var(--rl-danger-soft);
    color: #991b1b;
}

.alert-warning {
    background: var(--rl-warning-soft);
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
}

.rl-tenant-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    margin: -0.5rem 0 1.25rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: #1e3a5f;
}

.rl-tenant-bar-admin {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #14532d;
}

.rl-tenant-bar-sep {
    opacity: 0.45;
}

.rl-tenant-bar a {
    font-weight: 600;
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Page layout */
.rl-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.rl-page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}

.rl-subtitle {
    color: var(--rl-text-muted);
    margin: 0;
    font-size: 0.9375rem;
}

.rl-page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.rl-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.rl-badge-success { background: var(--rl-success-soft); color: var(--rl-success); }
.rl-badge-danger { background: var(--rl-danger-soft); color: var(--rl-danger); }
.rl-badge-muted { background: #f1f5f9; color: var(--rl-text-muted); }
.rl-badge-primary { background: var(--rl-primary-soft); color: var(--rl-primary); }

/* Stat cards */
.rl-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.rl-stat-card {
    background: var(--rl-surface);
    border: 1px solid var(--rl-border);
    border-radius: var(--rl-radius);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--rl-shadow);
    transition: transform var(--rl-transition), box-shadow var(--rl-transition);
}

.rl-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--rl-shadow-lg);
}

.rl-stat-card.rl-stat-success { border-left: 4px solid var(--rl-success); }
.rl-stat-card.rl-stat-danger { border-left: 4px solid var(--rl-danger); }
.rl-stat-card.rl-stat-primary { border-left: 4px solid var(--rl-primary); }

.rl-stat-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--rl-text-muted);
    margin-bottom: 0.35rem;
}

.rl-stat-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.rl-stat-value.text-success { color: var(--rl-success) !important; }
.rl-stat-value.text-danger { color: var(--rl-danger) !important; }

/* Panel / section */
.rl-panel {
    background: var(--rl-surface);
    border: 1px solid var(--rl-border);
    border-radius: var(--rl-radius);
    box-shadow: var(--rl-shadow);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.rl-panel-header {
    padding: 1rem 1.35rem;
    border-bottom: 1px solid var(--rl-border);
    background: #fafbfc;
}

.rl-panel-header h2,
.rl-panel-header h3 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
}

.rl-panel-body {
    padding: 1.25rem 1.35rem;
}

.rl-panel-footer {
    padding: 0.85rem 1.35rem;
    border-top: 1px solid var(--rl-border);
    background: #fafbfc;
}

/* Empty state */
.rl-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--rl-text-muted);
}

.rl-empty-icon {
    font-size: 2.5rem;
    opacity: 0.35;
    margin-bottom: 0.75rem;
}

/* Inbox */
.rl-inbox-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr;
    gap: 1rem;
    min-height: 480px;
}

@media (max-width: 768px) {
    .rl-inbox-layout {
        grid-template-columns: 1fr;
    }
}

.rl-conversation-list {
    background: var(--rl-surface);
    border: 1px solid var(--rl-border);
    border-radius: var(--rl-radius);
    box-shadow: var(--rl-shadow);
    overflow: hidden;
    max-height: 560px;
    overflow-y: auto;
}

.rl-conversation-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    border-bottom: 1px solid var(--rl-border);
    background: transparent;
    padding: 0.95rem 1.1rem;
    transition: background var(--rl-transition);
    cursor: pointer;
}

.rl-conversation-item:hover {
    background: #f8fafc;
}

.rl-conversation-item.active {
    background: var(--rl-primary-soft);
    border-left: 3px solid var(--rl-primary);
}

.rl-conversation-item .rl-conv-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--rl-text);
}

.rl-conversation-item .rl-conv-preview {
    font-size: 0.8125rem;
    color: var(--rl-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.15rem;
}

.rl-conversation-item .rl-conv-time {
    font-size: 0.75rem;
    color: var(--rl-text-muted);
}

.rl-thread {
    background: var(--rl-surface);
    border: 1px solid var(--rl-border);
    border-radius: var(--rl-radius);
    box-shadow: var(--rl-shadow);
    padding: 1.25rem;
    max-height: 420px;
    overflow-y: auto;
    background-image: radial-gradient(circle at 1px 1px, #e2e8f0 1px, transparent 0);
    background-size: 24px 24px;
    background-color: #f8fafc;
    flex: 1 1 auto;
}

.rl-thread-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 480px;
}

.rl-thread-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    background: var(--rl-surface);
    border: 1px solid var(--rl-border);
    border-radius: var(--rl-radius);
    box-shadow: var(--rl-shadow);
    padding: 0.85rem 1.1rem;
}

.rl-composer {
    background: var(--rl-surface);
    border: 1px solid var(--rl-border);
    border-radius: var(--rl-radius);
    box-shadow: var(--rl-shadow);
    padding: 0.75rem 0.85rem 0.65rem;
}

.rl-composer-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.45rem;
}

.rl-composer-input {
    flex: 1;
    min-height: 2.6rem;
    max-height: 7.5rem;
    resize: none;
    border: 1px solid var(--rl-border);
    border-radius: 1.25rem;
    padding: 0.65rem 0.95rem;
    font-size: 0.95rem;
    line-height: 1.35;
    background: #f8fafc;
    color: var(--rl-text);
}

.rl-composer-input:focus {
    outline: none;
    border-color: var(--rl-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.rl-composer-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.rl-composer-send {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 999px !important;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rl-composer-hint {
    margin-top: 0.4rem;
    font-size: 0.72rem;
    color: var(--rl-text-muted);
    padding-left: 2.9rem;
}

.rl-attach-wrap {
    position: relative;
    flex-shrink: 0;
}

.rl-attach-plus {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 999px;
    border: 1px solid var(--rl-border);
    background: #fff;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.rl-attach-plus:hover:not(:disabled) {
    background: #eef2ff;
    color: var(--rl-primary);
}

.rl-attach-plus.open {
    background: var(--rl-primary);
    border-color: var(--rl-primary);
    color: #fff;
    transform: rotate(45deg);
}

.rl-attach-plus:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rl-attach-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 0.45rem);
    z-index: 20;
    min-width: 15.5rem;
    background: #fff;
    border: 1px solid var(--rl-border);
    border-radius: 0.9rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.rl-attach-menu-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-align: left;
    border: 0;
    background: transparent;
    border-radius: 0.7rem;
    padding: 0.55rem 0.6rem;
    color: inherit;
}

.rl-attach-menu-item:hover:not(:disabled) {
    background: #f1f5f9;
}

.rl-attach-menu-item:disabled {
    opacity: 0.5;
}

.rl-attach-menu-item strong {
    display: block;
    font-size: 0.88rem;
    font-weight: 650;
}

.rl-attach-menu-item small {
    display: block;
    color: var(--rl-text-muted);
    font-size: 0.7rem;
}

.rl-attach-menu-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.rl-attach-menu-icon.photos {
    background: linear-gradient(135deg, #ec4899, #f43f5e);
}

.rl-attach-menu-icon.docs {
    background: linear-gradient(135deg, #6366f1, #3b82f6);
}

.rl-attach-menu-icon.media {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
}

.rl-file-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.rl-attach-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #f8fafc;
    border: 1px solid var(--rl-border);
    border-radius: 0.85rem;
    padding: 0.55rem 0.65rem;
    margin-bottom: 0.65rem;
}

.rl-attach-preview-img {
    width: 3.25rem;
    height: 3.25rem;
    object-fit: cover;
    border-radius: 0.55rem;
    flex-shrink: 0;
}

.rl-attach-preview-icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 0.55rem;
    background: #e2e8f0;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.rl-attach-preview-meta {
    min-width: 0;
    flex: 1;
}

.rl-attach-preview-name {
    font-weight: 650;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rl-attach-preview-sub {
    font-size: 0.72rem;
    color: var(--rl-text-muted);
    text-transform: capitalize;
}

.rl-attach-preview-remove {
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rl-attach-preview-remove:hover:not(:disabled) {
    background: #fecaca;
    color: #b91c1c;
}

.rl-conversation-item .rl-conv-window {
    font-size: 0.7rem;
    margin-top: 0.35rem;
    color: var(--rl-text-muted);
}

.rl-conversation-item .rl-conv-window.open {
    color: #15803d;
    font-weight: 600;
}

.rl-conversation-item .rl-conv-window.paused {
    color: #a16207;
    font-weight: 600;
}

.rl-conversation-item .rl-conv-new {
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: #dc2626;
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
}

.rl-inbox-filters {
    display: flex;
    gap: 0.35rem;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--rl-border);
    position: sticky;
    top: 0;
    background: var(--rl-surface);
    z-index: 1;
}

.rl-inbox-filter {
    border: 1px solid var(--rl-border);
    background: transparent;
    border-radius: 999px;
    font-size: 0.75rem;
    padding: 0.2rem 0.65rem;
    color: var(--rl-muted, #6b7280);
    cursor: pointer;
}

.rl-inbox-filter.active {
    background: var(--rl-primary, #0d6efd);
    border-color: var(--rl-primary, #0d6efd);
    color: #fff;
}

.rl-conversation-item .rl-conv-assign {
    font-size: 0.68rem;
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    background: #eef2ff;
    color: #3730a3;
}

.rl-conversation-item .rl-conv-assign.mine {
    background: #dcfce7;
    color: #166534;
}

.rl-conversation-item .rl-conv-assign.unassigned {
    background: #f3f4f6;
    color: #6b7280;
}

.rl-assign-bar {
    display: flex;
    justify-content: flex-end;
}

.rl-assign-select {
    min-width: 11rem;
    max-width: 14rem;
    margin-left: auto;
}

.rl-new-banner {
    display: flex;
    align-items: center;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    border-radius: var(--rl-radius);
    padding: 0.55rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.rl-bubble-new {
    outline: 2px solid #34d399;
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.25);
}

.rl-bubble-media {
    display: block;
    max-width: min(280px, 100%);
    max-height: 220px;
    border-radius: 0.5rem;
    margin: 0.25rem 0 0.4rem;
    object-fit: cover;
}

.rl-bubble-file {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 0.4rem;
    padding: 0.35rem 0.55rem;
    margin: 0.2rem 0 0.35rem;
    color: inherit;
    text-decoration: none;
    font-size: 0.85rem;
}

.rl-bubble-file:hover {
    text-decoration: underline;
}

.rl-bubble-source {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.85;
    margin-bottom: 0.2rem;
}

.rl-bubble-bot {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%) !important;
}

.rl-bubble-agent {
    background: linear-gradient(135deg, var(--rl-primary) 0%, #6366f1 100%) !important;
}

.rl-bubble-template {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%) !important;
}

.rl-bubble {
    display: inline-block;
    max-width: 78%;
    padding: 0.65rem 0.95rem;
    border-radius: 1rem;
    font-size: 0.9375rem;
    line-height: 1.45;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.rl-bubble-inbound {
    background: var(--rl-surface);
    border: 1px solid var(--rl-border);
    border-bottom-left-radius: 0.25rem;
}

.rl-bubble-outbound {
    background: linear-gradient(135deg, var(--rl-primary) 0%, #6366f1 100%);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.rl-bubble-meta {
    font-size: 0.7rem;
    opacity: 0.75;
    margin-top: 0.35rem;
}

.rl-brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    box-shadow: 0 2px 8px rgba(8, 29, 52, 0.12);
    object-fit: contain;
    padding: 0;
}

.rl-brand-logo {
    display: block;
    padding: 2px;
    background: #fff !important;
    box-shadow: 0 2px 8px rgba(8, 29, 52, 0.12) !important;
}

/* Auth layout card (inside AuthLayout) */
.rl-auth-wrap {
    min-height: calc(100vh - 4rem);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.rl-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--rl-surface);
    border: 1px solid var(--rl-border);
    border-radius: var(--rl-radius);
    box-shadow: var(--rl-shadow-lg);
    padding: 2rem;
}

.rl-auth-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.rl-auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.rl-auth-brand p {
    color: var(--rl-text-muted);
    font-size: 0.875rem;
    margin: 0;
}

/* Home hero */
.rl-hero {
    background: var(--rl-hero-gradient);
    border-radius: var(--rl-radius);
    color: #fff;
    padding: 2.5rem 2rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--rl-shadow-lg);
}

.rl-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.rl-hero .lead {
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 0;
}

.rl-feature-card {
    height: 100%;
    transition: transform var(--rl-transition);
}

.rl-feature-card:hover {
    transform: translateY(-4px);
}

.rl-feature-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--rl-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 1rem;
    background: var(--rl-primary-soft);
    color: var(--rl-primary);
}

/* Code blocks */
pre, code {
    font-family: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', monospace;
}

pre.bg-light, .rl-code-block {
    background: #0f172a !important;
    color: #e2e8f0;
    border-radius: var(--rl-radius-sm);
    padding: 1rem !important;
    font-size: 0.8125rem;
    border: none;
}

/* Loading */
.rl-loading {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--rl-text-muted);
    padding: 2rem 0;
}

.rl-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--rl-border);
    border-top-color: var(--rl-primary);
    border-radius: 50%;
    animation: rl-spin 0.7s linear infinite;
}

@keyframes rl-spin {
    to { transform: rotate(360deg); }
}

/* Tenant banner */
.rl-tenant-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background: var(--rl-primary-soft);
    border: 1px solid #c7d2fe;
    border-radius: var(--rl-radius-sm);
    font-size: 0.8125rem;
    color: #3730a3;
    margin-bottom: 1rem;
}

/* Blazor */
h1:focus { outline: none; }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--rl-success); }
.invalid { outline: 1px solid var(--rl-danger); }
.validation-message { color: var(--rl-danger); font-size: 0.8125rem; }

.blazor-error-boundary {
    background: var(--rl-danger);
    padding: 1rem 1.25rem;
    color: white;
    border-radius: var(--rl-radius-sm);
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.darker-border-checkbox.form-check-input {
    border-color: #94a3b8;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--rl-text-muted);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ---- App shell / sidebar (global — must not use scoped CSS) ---- */
:root {
    --rl-sidebar-width: 280px;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(99, 102, 241, 0.22);
}

html[data-sidebar-size="sm"] {
    --rl-sidebar-width: 84px;
}

/* Collapsed rail paint must live here (unscoped). MainLayout scoped CSS cannot
   style NavMenu's .rl-sidebar-inner — that left icons on a transparent/light rail. */
html[data-sidebar-size="sm"] .rl-sidebar,
.rl-sidebar.rl-sidebar--collapsed {
    overflow: visible;
    background: transparent;
    box-shadow: none;
}

html[data-sidebar-size="sm"] .rl-sidebar-inner,
.rl-sidebar.rl-sidebar--collapsed .rl-sidebar-inner {
    width: 84px;
    min-height: 100vh;
    height: 100%;
    background: var(--rl-sidebar-gradient);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
    /* overflow:visible for flyouts is reinforced below (after general scroll rules) */
    overflow: visible;
}

html[data-sidebar-size="lg"] .rl-sidebar,
.rl-sidebar:not(.rl-sidebar--collapsed) {
    overflow: hidden;
}

@media (max-width: 640.98px) {
    html[data-sidebar-drawer-open="true"] .rl-toggle-bars span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    html[data-sidebar-drawer-open="true"] .rl-toggle-bars span:nth-child(2) {
        opacity: 0;
    }

    html[data-sidebar-drawer-open="true"] .rl-toggle-bars span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }
}

/* Expanded: flyouts must never paint (prevents ghost second sidebar).
   Authority is the aside class — html[data-sidebar-size] can lag and was
   hiding flyouts while .rl-sidebar--collapsed + .nav-flyout.show were in the DOM. */
.rl-sidebar:not(.rl-sidebar--collapsed) .nav-flyout {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Collapsed icon rail — CSS hides labels; markup always stays in the DOM */
html[data-sidebar-size="sm"] .rl-sidebar .rl-brand-text,
html[data-sidebar-size="sm"] .rl-sidebar .brand-text,
html[data-sidebar-size="sm"] .rl-sidebar .nav-section,
html[data-sidebar-size="sm"] .rl-sidebar .nav-link-text,
html[data-sidebar-size="sm"] .rl-sidebar .nav-chevron,
html[data-sidebar-size="sm"] .rl-sidebar .rl-nav-user-meta,
html[data-sidebar-size="sm"] .rl-sidebar .nav-link-indicator,
html[data-sidebar-size="sm"] .rl-sidebar .sidebar-nav > .nav > .nav-tree-item > .nav-group > .nav-submenu,
html[data-sidebar-size="sm"] .rl-sidebar .sidebar-nav > .rl-sidebar-nav-list > .nav-tree-item > .nav-group > .nav-submenu,
.rl-sidebar.rl-sidebar--collapsed .rl-brand-text,
.rl-sidebar.rl-sidebar--collapsed .brand-text,
.rl-sidebar.rl-sidebar--collapsed .nav-section,
.rl-sidebar.rl-sidebar--collapsed .nav-link-text,
.rl-sidebar.rl-sidebar--collapsed .nav-chevron,
.rl-sidebar.rl-sidebar--collapsed .rl-nav-user-meta,
.rl-sidebar.rl-sidebar--collapsed .nav-link-indicator,
.rl-sidebar.rl-sidebar--collapsed .sidebar-nav > .nav > .nav-tree-item > .nav-group > .nav-submenu,
.rl-sidebar.rl-sidebar--collapsed .sidebar-nav > .rl-sidebar-nav-list > .nav-tree-item > .nav-group > .nav-submenu {
    display: none !important;
}

/* Flyout panels must keep labels when the rail is collapsed */
html[data-sidebar-size="sm"] .rl-sidebar .nav-flyout .nav-link-text,
html[data-sidebar-size="sm"] .rl-sidebar .nav-flyout .nav-chevron,
html[data-sidebar-size="sm"] .rl-sidebar .nav-flyout .nav-section,
html[data-sidebar-size="sm"] .rl-sidebar .nav-flyout .nav-link-indicator,
html[data-sidebar-size="sm"] .rl-sidebar .nav-flyout .nav-flyout-header,
html[data-sidebar-size="sm"] .rl-sidebar .nav-flyout .nav-submenu,
.rl-sidebar.rl-sidebar--collapsed .nav-flyout .nav-link-text,
.rl-sidebar.rl-sidebar--collapsed .nav-flyout .nav-chevron,
.rl-sidebar.rl-sidebar--collapsed .nav-flyout .nav-section,
.rl-sidebar.rl-sidebar--collapsed .nav-flyout .nav-link-indicator,
.rl-sidebar.rl-sidebar--collapsed .nav-flyout .nav-flyout-header,
.rl-sidebar.rl-sidebar--collapsed .nav-flyout .nav-submenu {
    display: revert !important;
}

/* Small rail: keep mark + expand chevron (do not hide the toggle — wrong icon/desync). */
html[data-sidebar-size="sm"] .rl-sidebar-brand,
html[data-sidebar-size="sm"] .sidebar-header,
.rl-sidebar.rl-sidebar--collapsed .rl-sidebar-brand,
.rl-sidebar.rl-sidebar--collapsed .sidebar-header {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 0.45rem;
}

html[data-sidebar-size="sm"] .rl-brand-link,
html[data-sidebar-size="sm"] .sidebar-brand,
.rl-sidebar.rl-sidebar--collapsed .rl-brand-link,
.rl-sidebar.rl-sidebar--collapsed .sidebar-brand {
    justify-content: center;
    flex: 0;
}

html[data-sidebar-size="sm"] .rl-sidebar-collapse-btn,
html[data-sidebar-size="sm"] .sidebar-collapse-btn,
.rl-sidebar.rl-sidebar--collapsed .rl-sidebar-collapse-btn,
.rl-sidebar.rl-sidebar--collapsed .sidebar-collapse-btn {
    display: grid !important;
    width: 32px;
    height: 32px;
}

html[data-sidebar-size="sm"] .sidebar-nav .nav-link,
html[data-sidebar-size="sm"] .sidebar-nav .nav-group-toggle,
.rl-sidebar.rl-sidebar--collapsed .sidebar-nav .nav-link,
.rl-sidebar.rl-sidebar--collapsed .sidebar-nav .nav-group-toggle {
    justify-content: center;
    padding-left: 0 !important;
    padding-right: 0 !important;
    gap: 0;
    min-height: 44px;
}

html[data-sidebar-size="sm"] .sidebar-user,
.rl-sidebar.rl-sidebar--collapsed .sidebar-user {
    justify-content: center;
    padding: 0.5rem 0;
}

html[data-sidebar-size="sm"] .rl-nav-footer,
html[data-sidebar-size="sm"] .sidebar-footer,
.rl-sidebar.rl-sidebar--collapsed .rl-nav-footer,
.rl-sidebar.rl-sidebar--collapsed .sidebar-footer {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
}

@media (min-width: 641px) {
    html[data-sidebar-size="sm"] .nav-tree-item.has-children > .nav-group > .nav-group-toggle,
    .rl-sidebar.rl-sidebar--collapsed .nav-tree-item.has-children > .nav-group > .nav-group-toggle {
        position: relative;
        z-index: 1;
    }

    /* Wide invisible bridge from icon rail → flyout (prevents hover drop in the gap) */
    html[data-sidebar-size="sm"] .nav-tree-item.has-children > .nav-group::after,
    .rl-sidebar.rl-sidebar--collapsed .nav-tree-item.has-children > .nav-group::after {
        content: "";
        position: absolute;
        top: -8px;
        bottom: -8px;
        right: -28px;
        width: 28px;
    }
}

.rl-nav-rail-form {
    margin: 0;
    width: 100%;
}

.rl-nav-rail-form .nav-link {
    width: 100%;
}

/* ---- HDMS-style nav items (global — child components of NavMenu) ---- */
.rl-sidebar .nav-section {
    padding: 1rem 0.85rem 0.45rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.42);
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
}

.rl-sidebar .nav-link,
.rl-sidebar .nav-group-toggle {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    min-height: 44px;
    margin-bottom: 0.2rem;
    padding: 0.6rem 0.85rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease, color 0.2s ease;
}

.rl-sidebar .nav-link:hover,
.rl-sidebar .nav-group-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    text-decoration: none;
}

.rl-sidebar .nav-link.active {
    background: var(--rl-sidebar-active);
    color: #fff;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rl-primary) 28%, transparent);
}

.rl-sidebar .nav-link-icon {
    width: 22px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.rl-sidebar .nav-link-icon .bi {
    font-size: 1.05rem;
}

.rl-sidebar .nav-link-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rl-sidebar .nav-link-indicator {
    position: absolute;
    right: 10px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
}

.rl-sidebar .nav-link.active .nav-link-indicator {
    background: #a5b4fc;
    box-shadow: 0 0 0 4px rgba(165, 180, 252, 0.18);
}

.rl-sidebar .nav-chevron {
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.7;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.rl-sidebar .nav-tree-item {
    position: relative;
}

.rl-sidebar .nav-tree-item .nav-link,
.rl-sidebar .nav-tree-item .nav-group-toggle {
    padding-left: calc(0.85rem + (var(--nav-level, 0) * 0.75rem));
}

.rl-sidebar .nav-tree-item.has-active-child > .nav-group > .nav-group-toggle {
    color: #fff;
}

.rl-sidebar .nav-tree-item.expanded > .nav-group > .nav-group-toggle .nav-chevron {
    transform: rotate(180deg);
}

.rl-sidebar .nav-submenu {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    margin-left: calc(0.85rem + (var(--nav-level, 0) * 0.75rem));
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.25s ease;
}

.rl-sidebar .nav-submenu.show {
    max-height: 3000px;
    opacity: 1;
    padding: 0.2rem 0 0.35rem 0.65rem;
}

.rl-sidebar .nav-submenu .nav-link,
.rl-sidebar .nav-submenu .nav-group-toggle {
    min-height: 40px;
    font-size: 0.86rem;
    margin-bottom: 0.12rem;
}

.rl-sidebar .nav-group {
    position: relative;
}

/* Keep an open flyout above neighboring rail icons / footer */
html[data-sidebar-size="sm"] .rl-sidebar .nav-tree-item.flyout-active,
html[data-sidebar-size="sm"] .rl-sidebar .nav-group.flyout-open,
.rl-sidebar.rl-sidebar--collapsed .nav-tree-item.flyout-active,
.rl-sidebar.rl-sidebar--collapsed .nav-group.flyout-open {
    z-index: 430;
}

.rl-sidebar .nav-flyout {
    position: absolute;
    top: 0;
    /* Overlap the rail slightly — no white dead-gap between icon and panel */
    left: calc(100% - 4px);
    z-index: 420;
    min-width: 240px;
    max-width: 290px;
    margin-left: 0;
    padding: 0.35rem;
    background: var(--rl-sidebar-elevated);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateX(8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    pointer-events: none;
}

/* Hit-test bridge attached to the panel (covers diagonal pointer paths).
   Inherits pointer-events from the flyout — inactive while the panel is closed. */
.rl-sidebar .nav-flyout::before {
    content: "";
    position: absolute;
    left: -28px;
    top: -12px;
    bottom: -12px;
    width: 32px;
}

.rl-sidebar.rl-sidebar--collapsed .nav-flyout.show,
.rl-sidebar.rl-sidebar--collapsed .nav-group.flyout-open > .nav-flyout,
.rl-sidebar.rl-sidebar--collapsed .nav-tree-item.flyout-active > .nav-group > .nav-flyout,
/* Browser hover backup — stays open without waiting on Blazor Server round-trip */
.rl-sidebar.rl-sidebar--collapsed .nav-group:hover > .nav-flyout {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}

.rl-sidebar .nav-flyout-header {
    padding: 0.55rem 0.75rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
}

.rl-sidebar .nav-flyout-body {
    padding: 0.15rem 0.25rem 0.35rem;
}

.rl-sidebar .nav-flyout-body .nav-link,
.rl-sidebar .nav-flyout-body .nav-group-toggle {
    color: #e2e8f0;
}

.rl-sidebar .nav-flyout .nav-tree-item.has-children > .nav-group > .nav-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    z-index: 430;
    min-width: 220px;
    margin-left: 8px;
    max-height: none;
    opacity: 0;
    visibility: hidden;
    padding: 0.35rem;
    border-left: none;
    background: var(--rl-sidebar-elevated);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.4);
}

.rl-sidebar .nav-flyout .nav-tree-item.has-children > .nav-group > .nav-submenu::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 0;
    width: 12px;
    height: 100%;
}

.rl-sidebar .nav-flyout .nav-tree-item.has-children:hover > .nav-group > .nav-submenu,
.rl-sidebar .nav-flyout .nav-tree-item.has-children.expanded > .nav-group > .nav-submenu.show,
.rl-sidebar .nav-flyout .nav-tree-item.has-children > .nav-group:focus-within > .nav-submenu {
    opacity: 1;
    visibility: visible;
}

.rl-sidebar .nav-flyout .nav-tree-item.has-children > .nav-group > .nav-group-toggle .nav-chevron {
    transform: rotate(-90deg);
}

/* Belt-and-suspenders: never allow Bootstrap .nav wrap inside the rail */
.rl-sidebar .sidebar-nav > .nav,
.rl-sidebar .nav-scrollable > .nav,
.rl-sidebar .sidebar-nav > .rl-sidebar-nav-list,
.rl-sidebar .nav-scrollable > .rl-sidebar-nav-list {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap !important;
    flex: 0 0 auto;
    width: 100%;
}

.rl-sidebar .sidebar-nav,
.rl-sidebar .nav-scrollable {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Collapsed: flyouts are position:absolute;left:100% — any ancestor with
   overflow != visible clips them (and CSS forbids overflow-x:visible with
   overflow-y:auto). Icon rail stays short; allow escape on every ancestor. */
html[data-sidebar-size="sm"] .rl-sidebar,
.rl-sidebar.rl-sidebar--collapsed {
    overflow: visible !important;
}

html[data-sidebar-size="sm"] .rl-sidebar .rl-sidebar-inner,
html[data-sidebar-size="sm"] .rl-sidebar-inner,
.rl-sidebar.rl-sidebar--collapsed .rl-sidebar-inner {
    overflow: visible !important;
}

html[data-sidebar-size="sm"] .rl-sidebar .sidebar-nav,
html[data-sidebar-size="sm"] .rl-sidebar .nav-scrollable,
.rl-sidebar.rl-sidebar--collapsed .sidebar-nav,
.rl-sidebar.rl-sidebar--collapsed .nav-scrollable {
    overflow: visible !important;
}

.rl-sidebar .rl-nav-footer,
.rl-sidebar .sidebar-footer {
    margin-top: auto;
    padding: 0.75rem 0.65rem 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.rl-sidebar .sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.5rem 0.65rem;
    min-width: 0;
}

.rl-sidebar .rl-nav-user-meta {
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.rl-sidebar .rl-nav-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--rl-avatar-gradient);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.rl-sidebar .rl-nav-user-name {
    color: #f1f5f9;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
}

.rl-sidebar .rl-nav-user-role {
    color: #94a3b8;
    font-size: 0.6875rem;
}

/* Theme picker (Account → Appearance) */
.rl-theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.rl-theme-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1rem;
    border: 1px solid var(--rl-border);
    border-radius: var(--rl-radius);
    background: var(--rl-surface);
    text-align: left;
    cursor: pointer;
    transition: border-color var(--rl-transition), box-shadow var(--rl-transition), transform var(--rl-transition);
}

.rl-theme-card:hover {
    border-color: color-mix(in srgb, var(--rl-primary) 45%, var(--rl-border));
    box-shadow: var(--rl-shadow);
    transform: translateY(-1px);
}

.rl-theme-card.is-selected {
    border-color: var(--rl-primary);
    box-shadow: 0 0 0 3px var(--rl-primary-soft);
}

.rl-theme-swatches {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
    height: 44px;
}

.rl-theme-swatches span {
    border-radius: 8px;
}

.rl-theme-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.rl-theme-card-body strong {
    color: var(--rl-text);
    font-size: 0.95rem;
}

.rl-theme-card-body small {
    color: var(--rl-text-muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.rl-theme-check {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    color: var(--rl-primary);
    font-size: 1.1rem;
}

/* —— Public marketing landing (/welcome) —— modern collaborative —— */
.rl-mkt-shell {
    min-height: 100vh;
    background: #fff;
    color: #081D34;
}

.rl-mkt {
    --mkt-navy: #081D34;
    --mkt-blue: #47C7F0;
    --mkt-blue-deep: #1FA8D4;
    --mkt-amber: #FFB300;
    --mkt-ice: #F1F1F1;
    --mkt-muted: #5b6b7c;
    --mkt-line: rgba(8, 29, 52, 0.08);
    --mkt-font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
    --mkt-radius: 10px;
    font-family: var(--mkt-font);
    color: var(--mkt-navy);
    background: #fff;
}

.rl-mkt-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem clamp(1.25rem, 4vw, 3rem);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--mkt-line);
}

.rl-mkt-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    color: var(--mkt-navy);
}

.rl-mkt-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: var(--mkt-navy);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.04em;
}

.rl-mkt-logo {
    display: block;
    height: 48px;
    width: auto;
    max-width: min(280px, 62vw);
    object-fit: contain;
}

@media (min-width: 768px) {
    .rl-mkt-logo {
        height: 56px;
        max-width: 320px;
    }
}

.rl-mkt-brand-name {
    font-weight: 700;
    letter-spacing: -0.04em;
    font-size: 1.12rem;
}

.rl-mkt-nav-actions {
    display: flex;
    align-items: center;
    gap: 1.35rem;
}

.rl-mkt-link {
    color: var(--mkt-muted);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: color 0.18s ease;
}

.rl-mkt-link:hover {
    color: var(--mkt-navy);
}

.rl-mkt-nav-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem;
    border-radius: var(--mkt-radius);
    background: var(--mkt-navy);
    color: #fff !important;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.18s ease;
}

.rl-mkt-nav-cta:hover {
    background: #0c2a4a;
    color: #fff !important;
}

.rl-mkt-hero {
    position: relative;
    overflow: hidden;
    min-height: min(88vh, 760px);
    padding: clamp(2.5rem, 6vh, 4.5rem) clamp(1.25rem, 4vw, 3rem) clamp(3rem, 7vh, 5rem);
}

.rl-mkt-hero-atmosphere {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 55% at 88% 18%, rgba(71, 199, 240, 0.16), transparent 60%),
        radial-gradient(ellipse 50% 45% at 8% 70%, rgba(8, 29, 52, 0.05), transparent 55%),
        linear-gradient(180deg, #F7F9FB 0%, #FFFFFF 48%, #F1F1F1 100%);
    pointer-events: none;
}

.rl-mkt-hero-grid {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
}

.rl-mkt-hero-copy {
    animation: rl-mkt-rise 0.7s ease both;
}

.rl-mkt-brand-hero {
    margin: 0 0 1rem;
    font-size: clamp(3rem, 8vw, 5.2rem);
    font-weight: 700;
    letter-spacing: -0.06em;
    line-height: 0.92;
    color: var(--mkt-navy);
}

.rl-mkt-brand-hero::after {
    content: "";
    display: block;
    width: 3.25rem;
    height: 3px;
    margin-top: 1rem;
    border-radius: 2px;
    background: var(--mkt-blue);
    animation: rl-mkt-bar 0.9s ease 0.2s both;
}

.rl-mkt-hero h1 {
    margin: 0 0 1rem;
    max-width: 14ch;
    font-size: clamp(1.45rem, 2.6vw, 2rem);
    font-weight: 600;
    letter-spacing: -0.035em;
    line-height: 1.22;
    color: var(--mkt-navy);
}

.rl-mkt-hero-lead {
    margin: 0 0 1.85rem;
    max-width: 32rem;
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--mkt-muted);
    font-weight: 450;
}

.rl-mkt-cta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.85rem;
    animation: rl-mkt-rise 0.8s ease 0.12s both;
}

.rl-mkt-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.35rem;
    border-radius: var(--mkt-radius);
    background: var(--mkt-navy);
    color: #fff !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.98rem;
    border: 1px solid var(--mkt-navy);
    transition: background 0.18s ease, border-color 0.18s ease;
}

.rl-mkt-btn-primary:hover {
    background: #0c2a4a;
    border-color: #0c2a4a;
    color: #fff !important;
}

.rl-mkt-btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.15rem;
    border-radius: var(--mkt-radius);
    background: transparent;
    color: var(--mkt-navy) !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.98rem;
    border: 1px solid var(--mkt-line);
    transition: border-color 0.18s ease, background 0.18s ease;
}

.rl-mkt-btn-ghost:hover {
    border-color: rgba(8, 29, 52, 0.22);
    background: rgba(8, 29, 52, 0.03);
}

.rl-mkt-btn-on-dark {
    background: #fff !important;
    border-color: #fff !important;
    color: var(--mkt-navy) !important;
}

.rl-mkt-btn-on-dark:hover {
    background: var(--mkt-blue) !important;
    border-color: var(--mkt-blue) !important;
    color: var(--mkt-navy) !important;
}

.rl-mkt-hero-stage {
    border: 1px solid var(--mkt-line);
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
    animation: rl-mkt-rise 0.85s ease 0.18s both;
    box-shadow: 0 24px 60px rgba(8, 29, 52, 0.08);
}

.rl-mkt-stage-chrome {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    background: var(--mkt-ice);
    border-bottom: 1px solid var(--mkt-line);
}

.rl-mkt-stage-chrome > span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d0d5db;
}

.rl-mkt-stage-chrome > span:nth-child(1) { background: #ffb4a8; }
.rl-mkt-stage-chrome > span:nth-child(2) { background: #ffd48a; }
.rl-mkt-stage-chrome > span:nth-child(3) { background: #9ad7a8; }

.rl-mkt-stage-title {
    margin-left: 0.55rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--mkt-muted);
    letter-spacing: 0.02em;
}

.rl-mkt-stage-body {
    display: grid;
    grid-template-columns: 0.42fr 0.58fr;
    min-height: 280px;
}

.rl-mkt-stage-list {
    padding: 0.65rem 0.5rem;
    border-right: 1px solid var(--mkt-line);
    background: #fafbfc;
}

.rl-mkt-stage-row {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.55rem 0.45rem;
    border-radius: 8px;
    margin-bottom: 0.2rem;
}

.rl-mkt-stage-row.is-active {
    background: rgba(71, 199, 240, 0.12);
}

.rl-mkt-stage-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(145deg, #47C7F0, #1FA8D4);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    display: grid;
    place-items: center;
}

.rl-mkt-stage-avatar.muted {
    background: linear-gradient(145deg, #c5d0db, #9aabbc);
}

.rl-mkt-stage-meta {
    min-width: 0;
}

.rl-mkt-stage-name {
    font-size: 0.78rem;
    font-weight: 650;
    color: var(--mkt-navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    height: auto;
    width: auto;
    background: none;
    border-radius: 0;
}

.rl-mkt-stage-preview {
    font-size: 0.7rem;
    color: var(--mkt-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0.1rem 0 0;
    height: auto;
    width: auto;
    opacity: 1;
    background: none;
    border-radius: 0;
}

.rl-mkt-stage-time {
    font-size: 0.62rem;
    color: #94a3b8;
    font-weight: 500;
    align-self: start;
    padding-top: 0.15rem;
}

.rl-mkt-stage-thread {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1rem 0.95rem 0.9rem;
    justify-content: flex-end;
    min-height: 280px;
}

.rl-mkt-stage-bubble {
    max-width: 88%;
    width: fit-content;
    height: auto;
    border-radius: 12px;
    background: var(--mkt-ice);
    color: var(--mkt-navy);
    font-size: 0.78rem;
    line-height: 1.4;
    padding: 0.55rem 0.75rem;
    font-weight: 500;
}

.rl-mkt-stage-bubble.out {
    align-self: flex-end;
    background: var(--mkt-navy);
    color: #fff;
    max-width: 86%;
}

.rl-mkt-stage-bubble.short {
    max-width: 70%;
    height: auto;
}

.rl-mkt-stage-composer {
    margin-top: 0.4rem;
    min-height: 38px;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--mkt-line);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem 0.45rem 0.75rem;
    font-size: 0.74rem;
    color: #94a3b8;
}

.rl-mkt-stage-send {
    background: var(--mkt-navy);
    color: #fff;
    font-weight: 650;
    font-size: 0.68rem;
    border-radius: 7px;
    padding: 0.35rem 0.65rem;
}

.rl-mkt-showcase {
    padding: 1rem clamp(1.25rem, 4vw, 3rem) 4rem;
    background: var(--mkt-ice);
}

.rl-mkt-showcase-head {
    text-align: left;
    max-width: 1180px;
    margin: 0 auto 1.75rem;
}

.rl-mkt-showcase-head h2,
.rl-mkt-section h2 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.55rem, 2.6vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--mkt-navy);
}

.rl-mkt-showcase-head p {
    margin: 0;
    color: var(--mkt-muted);
    font-size: 1.02rem;
}

.rl-mkt-slider {
    max-width: 1180px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--mkt-line);
    border-radius: 16px;
    overflow: hidden;
}

.rl-mkt-slider-viewport {
    position: relative;
    min-height: 260px;
}

.rl-mkt-slides {
    position: relative;
}

.rl-mkt-slide {
    display: none;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 1.5rem;
    padding: clamp(1.5rem, 3vw, 2.4rem);
    align-items: center;
    animation: rl-mkt-rise 0.4s ease both;
}

.rl-mkt-slide.is-active {
    display: grid;
}

.rl-mkt-slide-kicker {
    display: inline-block;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mkt-blue-deep);
}

.rl-mkt-slide-copy h3 {
    margin: 0 0 0.65rem;
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    font-weight: 650;
    letter-spacing: -0.03em;
}

.rl-mkt-slide-copy p {
    margin: 0;
    color: var(--mkt-muted);
    line-height: 1.6;
    max-width: 34rem;
}

.rl-mkt-slide-visual {
    display: flex;
    justify-content: center;
}

.rl-mkt-mock {
    width: min(100%, 280px);
    border-radius: 14px;
    background: var(--mkt-navy);
    color: #fff;
    padding: 1rem;
}

.rl-mkt-mock-inbox {
    display: grid;
    grid-template-columns: 0.35fr 1fr;
    gap: 0.65rem;
    min-height: 150px;
}

.rl-mkt-mock-side {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-top: 0.2rem;
}

.rl-mkt-mock-pill {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
}

.rl-mkt-mock-pill.active {
    background: var(--mkt-blue);
}

.rl-mkt-mock-thread {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    justify-content: center;
}

.rl-mkt-mock-bubble {
    height: 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    width: 78%;
}

.rl-mkt-mock-bubble.out {
    align-self: flex-end;
    background: rgba(71, 199, 240, 0.45);
    width: 62%;
}

.rl-mkt-mock-bubble.short {
    width: 48%;
}

.rl-mkt-mock-code {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
}

.rl-mkt-mock-code .dim {
    color: rgba(255, 255, 255, 0.5);
}

.rl-mkt-mock-code .ok {
    color: var(--mkt-amber);
}

.rl-mkt-mock-bot {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.rl-mkt-mock-menu {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 0.65rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
}

.rl-mkt-mock-badge {
    align-self: flex-start;
    margin-top: 0.35rem;
    background: var(--mkt-amber);
    color: var(--mkt-navy);
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 6px;
    padding: 0.28rem 0.55rem;
}

.rl-mkt-mock-hooks {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    min-height: 150px;
    justify-content: center;
}

.rl-mkt-mock-node {
    width: 100%;
    text-align: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 0.65rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.85rem;
}

.rl-mkt-mock-node.accent {
    background: rgba(71, 199, 240, 0.28);
}

.rl-mkt-mock-line {
    width: 2px;
    height: 14px;
    background: rgba(255, 255, 255, 0.22);
}

.rl-mkt-slider-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    padding: 0 1rem 1.15rem;
}

.rl-mkt-slider-btn {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 8px;
    border: 1px solid var(--mkt-line);
    background: #fff;
    color: var(--mkt-navy);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.rl-mkt-slider-btn:hover {
    border-color: rgba(8, 29, 52, 0.2);
    background: var(--mkt-ice);
}

.rl-mkt-slider-dots {
    display: flex;
    gap: 0.4rem;
}

.rl-mkt-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    border: 0;
    background: #c9d2dc;
    padding: 0;
}

.rl-mkt-dot.is-active {
    width: 1.2rem;
    background: var(--mkt-navy);
}

.rl-mkt-section {
    padding: 4.25rem clamp(1.25rem, 4vw, 3rem);
    background: #fff;
}

.rl-mkt-section-alt {
    background: var(--mkt-ice);
    border-block: 1px solid var(--mkt-line);
}

.rl-mkt-section-inner {
    max-width: 1180px;
    margin: 0 auto;
}

.rl-mkt-section-lead {
    color: var(--mkt-muted);
    max-width: 38rem;
    margin: 0 0 2.25rem;
    line-height: 1.6;
    font-size: 1.02rem;
}

.rl-mkt-groups {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.15rem;
}

.rl-mkt-group {
    padding: 1.5rem 0 0;
    border-top: 2px solid var(--mkt-navy);
}

.rl-mkt-group h3 {
    margin: 0 0 0.9rem;
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.rl-mkt-group ul {
    margin: 0;
    padding-left: 1.05rem;
    color: var(--mkt-muted);
    display: grid;
    gap: 0.5rem;
    font-size: 0.94rem;
    line-height: 1.45;
}

.rl-mkt-split {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 2.5rem;
    align-items: start;
}

.rl-mkt-roadmap {
    margin: 0;
    padding-left: 1.15rem;
    color: var(--mkt-navy);
    display: grid;
    gap: 0.7rem;
    max-width: 36rem;
    font-size: 0.98rem;
    line-height: 1.45;
}

.rl-mkt-roadmap li::marker {
    color: var(--mkt-blue-deep);
}

.rl-mkt-footer-cta {
    padding: 4.5rem clamp(1.25rem, 4vw, 3rem);
    background: var(--mkt-navy);
    color: #fff;
    text-align: center;
}

.rl-mkt-footer-cta-inner {
    max-width: 34rem;
    margin: 0 auto;
}

.rl-mkt-footer-cta h2 {
    margin: 0 0 0.55rem;
    font-size: clamp(1.45rem, 2.5vw, 1.9rem);
    font-weight: 700;
    letter-spacing: -0.04em;
}

.rl-mkt-footer-cta p {
    color: rgba(255, 255, 255, 0.72);
    margin: 0 0 1.5rem;
}

.rl-mkt-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    justify-content: space-between;
    padding: 1.35rem clamp(1.25rem, 4vw, 3rem) 2rem;
    color: var(--mkt-muted);
    font-size: 0.85rem;
    background: #fff;
    border-top: 1px solid var(--mkt-line);
}

.rl-mkt-footer-muted {
    color: #8a97a6;
}

@keyframes rl-mkt-rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rl-mkt-bar {
    from {
        opacity: 0;
        transform: scaleX(0.35);
        transform-origin: left center;
    }
    to {
        opacity: 1;
        transform: scaleX(1);
        transform-origin: left center;
    }
}

@media (max-width: 960px) {
    .rl-mkt-hero-grid {
        grid-template-columns: 1fr;
        gap: 2.25rem;
    }

    .rl-mkt-hero {
        min-height: auto;
        padding-bottom: 2.5rem;
    }

    .rl-mkt-groups {
        grid-template-columns: 1fr;
    }

    .rl-mkt-slide {
        grid-template-columns: 1fr;
    }

    .rl-mkt-slide-visual {
        order: -1;
    }
}

@media (max-width: 800px) {
    .rl-mkt-split {
        grid-template-columns: 1fr;
    }

    .rl-mkt-link {
        display: none;
    }

    .rl-mkt-stage-body {
        grid-template-columns: 1fr;
    }

    .rl-mkt-stage-list {
        display: none;
    }
}

/* Global fallback: hide Blazor error banner until an actual circuit error */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
    padding: 0.75rem 1.25rem;
    background: #fef3c7;
    border-top: 1px solid #fcd34d;
    font-size: 0.875rem;
}

#blazor-error-ui.show,
.blazor-error-boundary {
    display: block;
}
