/* =========================================================
   Ianua · design tokens
   ========================================================= */
:root {
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --text: #0f172a;
    --text-2: #334155;
    --text-muted: #64748b;      /* 4.7:1 sobre blanco */

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: rgba(79, 70, 229, 0.10);
    --primary-rgb: 79, 70, 229;
    --ring: rgba(79, 70, 229, 0.30);

    --success: #15803d;
    --success-soft: rgba(22, 163, 74, 0.12);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --warning: #b45309;
    --warning-soft: rgba(217, 119, 6, 0.12);

    --code-bg: #0f172a;
    --code-text: #e2e8f0;
    --code-keyword: #93c5fd;
    --code-string: #fcd34d;
    --code-comment: #64748b;
    --code-ident: #a5f3fc;

    --sidebar-bg: #0f172a;
    --sidebar-text: rgba(255, 255, 255, 0.72);
    --sidebar-text-strong: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(129, 140, 248, 0.22);

    --r-sm: 0.5rem;
    --r: 0.75rem;
    --r-lg: 1rem;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 20px 50px -20px rgba(15, 23, 42, 0.35);

    --sidebar-width: 248px;
    --sidebar-rail: 68px;
    --mobile-bar-height: 56px;
    --ease: cubic-bezier(0.2, 0, 0, 1);
    --dur: 180ms;

    /* Bootstrap bridge */
    --bs-font-sans-serif: var(--font-sans);
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--border);
    --bs-secondary-color: var(--text-muted);
    --bs-tertiary-bg: var(--surface-2);
    --bs-primary: var(--primary);
    --bs-primary-rgb: var(--primary-rgb);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-hover);
    --bs-border-radius: var(--r-sm);
}

[data-bs-theme="dark"] {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #0f172a;
    --surface-3: #1e293b;
    --border: #1f2937;
    --border-strong: #334155;

    --text: #e5e7eb;
    --text-2: #cbd5e1;
    --text-muted: #94a3b8;

    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: rgba(129, 140, 248, 0.16);
    --primary-rgb: 129, 140, 248;
    --ring: rgba(129, 140, 248, 0.35);

    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.14);

    --code-bg: #020617;
    --code-text: #e2e8f0;

    --sidebar-bg: #060b16;
    --sidebar-active: rgba(129, 140, 248, 0.26);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 20px 50px -20px rgba(0, 0, 0, 0.8);

    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--border);
    --bs-secondary-color: var(--text-muted);
    --bs-tertiary-bg: var(--surface-2);
}

/* =========================================================
   Base
   ========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    z-index: 10000;
    padding: 0.5rem 0.75rem;
    background: var(--primary);
    color: #fff;
    border-radius: var(--r-sm);
    transition: top var(--dur) var(--ease);
}

.skip-link:focus {
    top: 1rem;
    color: #fff;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* =========================================================
   Page loader
   ========================================================= */
.page-loader {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 9999;
    transition: opacity 250ms var(--ease), visibility 250ms var(--ease);
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.page-loader .loader-logo {
    font-size: 2.25rem;
    display: flex;
    color: var(--primary);
}

.page-loader .loader-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.page-loader .loader-text {
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

/* =========================================================
   Iconos SVG
   ========================================================= */
.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: -0.125em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.icon-spin {
    animation: spin 0.9s linear infinite;
}

.icon-lg {
    font-size: 1.25em;
}

/* =========================================================
   Shell: sidebar (rail colapsable) + barra móvil
   ========================================================= */
#wrapper {
    display: flex;
    min-height: 100dvh;
}

#sidebar-wrapper {
    width: var(--sidebar-width);
    height: 100dvh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: width var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.sb-sidenav {
    height: 100%;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.sb-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.875rem 0.75rem 0.5rem 1rem;
    min-height: 60px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--sidebar-text-strong);
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    min-width: 0;
}

.brand-link .icon {
    color: #a5b4fc;
    font-size: 1.35rem;
}

.brand-link:hover {
    color: var(--sidebar-text-strong);
}

.sb-sidenav .icon-btn {
    color: var(--sidebar-text);
}

.sb-sidenav .icon-btn:hover {
    color: var(--sidebar-text-strong);
    background: var(--sidebar-hover);
}

.sb-sidenav-menu {
    flex: 1;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.sb-sidenav-menu .nav-link {
    color: var(--sidebar-text);
    padding: 0.65rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: var(--r-sm);
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.sb-sidenav-menu .nav-link .icon {
    font-size: 1.15rem;
    opacity: 0.85;
}

.sb-sidenav-menu .nav-link:hover {
    color: var(--sidebar-text-strong);
    background: var(--sidebar-hover);
}

.sb-sidenav-menu .nav-link.active {
    color: var(--sidebar-text-strong);
    background: var(--sidebar-active);
    font-weight: 600;
}

.sb-sidenav-menu .nav-link.active .icon {
    color: #a5b4fc;
    opacity: 1;
}

.sb-sidenav-footer {
    padding: 0.75rem 0.75rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sb-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    padding: 0 0.25rem;
}

.sb-avatar {
    font-size: 1.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.sb-user-text {
    min-width: 0;
}

.sb-user-text .small {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    line-height: 1.2;
}

.sb-user-text span {
    color: var(--sidebar-text-strong);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
    font-weight: 600;
}

.sb-footer-actions {
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
}

.sb-footer-actions .icon-btn {
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

#content-wrapper {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    transition: margin var(--dur) var(--ease);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    font-size: 1.1rem;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

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

/* Barra móvil */
.mobile-bar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 90;
    height: var(--mobile-bar-height);
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.75rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    font-size: 1.05rem;
}

.mobile-brand .icon {
    color: var(--primary);
    font-size: 1.25rem;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.5);
    z-index: 95;
}

.dropdown-menu {
    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-border-color: var(--border);
    --bs-dropdown-color: var(--text);
    --bs-dropdown-link-color: var(--text-2);
    --bs-dropdown-link-hover-color: var(--text);
    --bs-dropdown-link-hover-bg: var(--surface-3);
    --bs-dropdown-border-radius: var(--r);
    box-shadow: var(--shadow);
    padding: 0.375rem;
}

/* Escritorio: rail de iconos */
@media (min-width: 992px) {
    body.sb-sidenav-toggled {
        --sidebar-width: var(--sidebar-rail);
    }

    body.sb-sidenav-toggled .label,
    body.sb-sidenav-toggled .sb-user-text {
        display: none;
    }

    body.sb-sidenav-toggled .sb-brand {
        flex-direction: column;
        padding: 0.75rem 0 0.25rem;
        gap: 0.25rem;
    }

    body.sb-sidenav-toggled .sb-brand .brand-link {
        justify-content: center;
    }

    body.sb-sidenav-toggled .sb-collapse .icon {
        transform: rotate(180deg);
    }

    body.sb-sidenav-toggled .sb-sidenav-menu {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    body.sb-sidenav-toggled .sb-sidenav-menu .nav-link {
        justify-content: center;
        padding: 0.7rem 0;
    }

    body.sb-sidenav-toggled .sb-sidenav-footer {
        gap: 0.25rem;
        padding: 0.75rem 0.5rem;
        align-items: center;
    }

    body.sb-sidenav-toggled .sb-user {
        justify-content: center;
        padding: 0;
    }

    body.sb-sidenav-toggled .sb-footer-actions {
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    body.sb-sidenav-toggled .sb-footer-actions .icon-btn {
        border: none;
    }

    /* Evita la animación de ancho en la primera pintura si ya estaba colapsado */
    html.sb-pre-collapsed #sidebar-wrapper,
    html.sb-pre-collapsed #content-wrapper {
        transition: none;
    }
}

/* Móvil: cajón lateral */
@media (max-width: 991.98px) {
    .mobile-bar {
        display: flex;
    }

    #sidebar-wrapper {
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 84vw);
    }

    body.sb-sidenav-toggled #sidebar-wrapper {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .sb-collapse {
        display: none;
    }

    #content-wrapper {
        margin-left: 0;
    }
}

/* =========================================================
   Page layout
   ========================================================= */
.page {
    padding: clamp(1.25rem, 2.5vw, 2rem) clamp(1rem, 2.5vw, 2rem) 3rem;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 0.35rem;
    color: var(--text);
}

.page-lead {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
    max-width: 70ch;
}

.page-lead code {
    font-family: var(--font-mono);
    font-size: 0.8em;
    background: var(--surface-3);
    color: var(--text-2);
    padding: 0.1em 0.4em;
    border-radius: 0.3em;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@media (min-width: 1200px) {
    .workspace {
        grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
        gap: 1.5rem;
    }

    .result-pane {
        position: sticky;
        top: 1.25rem;
        max-height: calc(100dvh - 2.5rem);
    }
}

.steps {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

/* =========================================================
   Cards
   ========================================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: visible;
    color: var(--text);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 0.875rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    color: var(--text);
    font-size: 0.95rem;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    padding: 1rem 1.25rem;
}

/* Steps */
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 0.8rem;
    font-weight: 800;
    flex-shrink: 0;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.step.is-done .step-badge {
    background: var(--success-soft);
    color: var(--success);
}

.step-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-title > .icon {
    color: var(--text-muted);
}

.step-status {
    margin-left: auto;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--success);
    display: none;
    align-items: center;
    gap: 0.35rem;
}

.step.is-done .step-status {
    display: inline-flex;
}

.step-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* =========================================================
   Forms
   ========================================================= */
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem 1.25rem;
}

.field-grid .field-full {
    grid-column: 1 / -1;
}

.field label,
.form-label {
    display: block;
    color: var(--text-2);
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.field-hint,
.form-text {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.35rem;
}

.form-control,
.form-select {
    background-color: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text);
    padding: 0.6rem 0.875rem;
    font-size: 0.9rem;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.form-control:hover:not(:disabled),
.form-select:hover:not(:disabled) {
    border-color: var(--text-muted);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
    color: var(--text);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

.form-control:disabled,
.form-select:disabled {
    background-color: var(--surface-2);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 1;
}

.form-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.1rem;
    cursor: pointer;
}

.form-select option {
    background: var(--surface);
    color: var(--text);
}

/* Skeleton loading state for selects */
.form-select.is-loading {
    color: transparent;
    pointer-events: none;
    background-image: linear-gradient(90deg,
        var(--surface-3) 0%,
        var(--surface-2) 40%,
        var(--surface-3) 80%);
    background-size: 200% 100%;
    animation: shimmer 1.2s linear infinite;
    border-color: var(--border);
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* Input group (password) */
.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .btn {
    border: 1px solid var(--border-strong);
    border-left: none;
    background: var(--surface);
    color: var(--text-2);
    padding: 0 0.875rem;
    border-radius: 0;
}

.input-group .btn:last-child {
    border-top-right-radius: var(--r-sm);
    border-bottom-right-radius: var(--r-sm);
}

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

.input-group .form-control:focus {
    z-index: 2;
}

.form-check-input {
    width: 1.15rem;
    height: 1.15rem;
    margin: 0;
    background-color: var(--surface);
    border: 1.5px solid var(--border-strong);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}

.form-check-input:indeterminate {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* =========================================================
   Buttons
   ========================================================= */
.btn .icon {
    font-size: 1.1em;
}

.btn {
    --bs-btn-border-radius: var(--r-sm);
    --bs-btn-font-weight: 700;
    --bs-btn-padding-y: 0.55rem;
    --bs-btn-padding-x: 1rem;
    --bs-btn-font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--primary-hover);
    --bs-btn-active-border-color: var(--primary-hover);
    --bs-btn-active-color: #fff;
    --bs-btn-disabled-bg: var(--primary);
    --bs-btn-disabled-border-color: var(--primary);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-opacity: 0.5;
    --bs-btn-focus-shadow-rgb: var(--primary-rgb);
}

[data-bs-theme="dark"] .btn-primary {
    --bs-btn-color: #0b1120;
    --bs-btn-hover-color: #0b1120;
    --bs-btn-active-color: #0b1120;
    --bs-btn-disabled-color: #0b1120;
}

.btn-ghost {
    --bs-btn-bg: transparent;
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-color: var(--text-2);
    --bs-btn-hover-bg: var(--surface-3);
    --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-hover-color: var(--text);
    --bs-btn-active-bg: var(--surface-3);
    --bs-btn-active-border-color: var(--border-strong);
    --bs-btn-active-color: var(--text);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: var(--border);
    --bs-btn-disabled-color: var(--text-muted);
    --bs-btn-focus-shadow-rgb: var(--primary-rgb);
}

.btn-ghost.is-success {
    --bs-btn-color: var(--success);
    --bs-btn-border-color: var(--success);
}

.btn-danger-soft {
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-color: var(--danger);
    --bs-btn-hover-bg: var(--danger-soft);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-hover-color: var(--danger);
    --bs-btn-active-bg: var(--danger-soft);
    --bs-btn-active-color: var(--danger);
    --bs-btn-disabled-color: var(--text-muted);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: transparent;
    --bs-btn-focus-shadow-rgb: 220, 38, 38;
}

.btn-sm {
    --bs-btn-padding-y: 0.35rem;
    --bs-btn-padding-x: 0.7rem;
    --bs-btn-font-size: 0.8rem;
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary);
    --bs-btn-active-border-color: var(--primary);
    --bs-btn-focus-shadow-rgb: var(--primary-rgb);
}

.btn-secondary {
    --bs-btn-bg: var(--surface-3);
    --bs-btn-border-color: var(--surface-3);
    --bs-btn-color: var(--text-2);
    --bs-btn-hover-bg: var(--border);
    --bs-btn-hover-border-color: var(--border);
    --bs-btn-hover-color: var(--text);
    --bs-btn-active-bg: var(--border);
    --bs-btn-active-color: var(--text);
}

/* =========================================================
   Table search (combobox)
   ========================================================= */
.search-field {
    position: relative;
}

.search-field .form-control {
    padding-left: 2.4rem;
}

.search-field > .search-icon {
    font-size: 1rem;
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-with-clear {
    padding-right: 2.5rem;
}

.search-clear-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), opacity var(--dur) var(--ease);
    opacity: 0;
    visibility: hidden;
    z-index: 5;
}

.search-clear-btn.show {
    opacity: 1;
    visibility: visible;
}

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

.search-dropdown {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow-y: auto;
    padding: 0.35rem;
}

.search-dropdown:empty {
    display: none;
}

.search-dropdown .search-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.6rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.search-dropdown .search-hint {
    padding: 0.6rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.7rem;
    border: none;
    background: transparent;
    color: var(--text);
    border-radius: var(--r-sm);
    text-align: left;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background var(--dur) var(--ease);
}

.search-option > span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.search-option > span > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-option > span > .icon {
    color: var(--text-muted);
}

.search-option:hover,
.search-option.is-active {
    background: var(--surface-3);
}

.search-option[aria-disabled="true"] {
    color: var(--text-muted);
    cursor: default;
}

.search-option .icon-add {
    color: var(--primary);
}

.search-option .icon-added {
    color: var(--success);
}

/* =========================================================
   Permissions matrix
   ========================================================= */
.perm-table-wrap {
    margin-top: 1rem;
    overflow: auto;
    max-height: min(52vh, 460px);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overscroll-behavior: contain;
}

.perm-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.perm-table tbody tr.is-new td {
    animation: rowFlash 1.4s var(--ease);
}

@keyframes rowFlash {
    0% { background-color: var(--primary-soft); }
    60% { background-color: var(--primary-soft); }
    100% { background-color: transparent; }
}

.perm-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
    color: var(--text);
    margin: 0;
}

.perm-table thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
    white-space: nowrap;
}

.perm-table thead th:first-child {
    text-align: left;
}

.perm-table tbody td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
    vertical-align: middle;
}

.perm-table tbody tr:last-child td {
    border-bottom: none;
}

.perm-table tbody td:first-child {
    text-align: left;
}

.perm-table tbody tr:hover td {
    background: var(--surface-2);
}

.perm-table .perm-name {
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

.perm-table .perm-db {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.perm-table .perm-all {
    border-left: 1px solid var(--border);
}

.perm-table .form-check-input {
    vertical-align: middle;
}

.perm-table .btn-danger-soft {
    width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    border-radius: 50%;
    font-size: 1rem;
}

.perm-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.78rem;
}

@media (max-width: 575.98px) {
    .perm-table-wrap {
        border: none;
        border-radius: 0;
        overflow: visible;
        max-height: none;
    }

    .perm-table tbody tr.is-new {
        animation: rowFlash 1.4s var(--ease);
    }

    .perm-table tbody tr.is-new td {
        animation: none;
    }

    .perm-table,
    .perm-table tbody,
    .perm-table tr,
    .perm-table td {
        display: block;
    }

    .perm-table thead {
        display: none;
    }

    .perm-table tr {
        position: relative;
        border: 1px solid var(--border);
        border-radius: var(--r);
        padding: 0.75rem 0.9rem 0.5rem;
        margin-bottom: 0.75rem;
        background: var(--surface);
    }

    .perm-table tbody tr:hover td {
        background: transparent;
    }

    .perm-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.4rem 0;
        border: none;
        text-align: left;
    }

    .perm-table tbody td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .perm-table tbody td:first-child {
        display: block;
        padding: 0 2.25rem 0.5rem 0;
        margin-bottom: 0.25rem;
        border-bottom: 1px solid var(--border);
    }

    .perm-table tbody td:first-child::before {
        display: none;
    }

    .perm-table .perm-name {
        max-width: none;
        white-space: normal;
    }

    .perm-table .perm-all {
        border-left: none;
        border-top: 1px solid var(--border);
        margin-top: 0.25rem;
        padding-top: 0.6rem;
    }

    .perm-table td.perm-remove {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        padding: 0;
    }

    .perm-table td.perm-remove::before {
        display: none;
    }
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    color: var(--text-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r);
    margin-top: 1rem;
    font-size: 0.875rem;
}

.empty-state > .icon {
    font-size: 1.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.empty-state strong {
    color: var(--text-2);
}

.empty-state ol {
    text-align: left;
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
    line-height: 1.7;
}

/* =========================================================
   Result pane
   ========================================================= */
.result-pane {
    display: flex;
    flex-direction: column;
    min-height: 420px;
    min-width: 0;
}

.result-pane .card-header {
    flex-wrap: wrap;
}

.result-summary {
    margin-left: auto;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.chip.chip-primary {
    background: var(--primary-soft);
    color: var(--primary);
}

.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.action-bar .btn-primary {
    flex: 1 1 auto;
}

.result-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--code-bg);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
    overflow: hidden;
}

.result-body .empty-state {
    margin: 1.25rem;
    flex: 1;
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(226, 232, 240, 0.7);
}

.result-body .empty-state > .icon,
.result-body .empty-state strong {
    color: rgba(226, 232, 240, 0.9);
}

.sql-output {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 1.25rem;
    background: transparent;
    color: var(--code-text);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    tab-size: 4;
}

.sql-output .tok-kw { color: var(--code-keyword); font-weight: 700; }
.sql-output .tok-str { color: var(--code-string); }
.sql-output .tok-cm { color: var(--code-comment); font-style: italic; }
.sql-output .tok-id { color: var(--code-ident); }

.sql-output::-webkit-scrollbar {
    width: 8px;
}

.sql-output::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
}

/* =========================================================
   Toasts
   ========================================================= */
.toast-stack {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(380px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast-item {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.8rem 0.9rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    animation: toastIn 200ms var(--ease);
}

.toast-item.is-error { border-left-color: var(--danger); }
.toast-item.is-success { border-left-color: var(--success); }
.toast-item.is-error > .icon { color: var(--danger); }
.toast-item.is-success > .icon { color: var(--success); }

.toast-item > .icon {
    margin-top: 0.15rem;
    font-size: 1.1rem;
}

.toast-item .toast-msg {
    flex: 1;
    min-width: 0;
}

.toast-item .toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    font-size: 1.1rem;
}

.toast-item .toast-close:hover {
    color: var(--text);
}

.toast-item.is-leaving {
    animation: toastOut 160ms var(--ease) forwards;
}

@media (max-width: 991.98px) {
    .toast-stack {
        top: calc(var(--mobile-bar-height) + 0.75rem);
    }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateY(-6px); }
}

/* Legacy alert styles kept for the users page */
#alerts .alert {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
}

#alerts .alert-danger { border-left: 4px solid var(--danger); }
#alerts .alert-success { border-left: 4px solid var(--success); }

/* =========================================================
   Custom modal (ticket)
   ========================================================= */
.custom-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 1070;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.custom-modal-overlay.show {
    display: flex;
}

.custom-modal {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    width: 100%;
    max-width: 720px;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: toastIn 200ms var(--ease);
}

.custom-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.custom-modal-header h2,
.custom-modal-header h5 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.custom-modal-header h2 .icon,
.custom-modal-header h5 .icon {
    color: var(--warning);
}

.custom-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.15rem;
    cursor: pointer;
    line-height: 1;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--r-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.custom-modal-close:hover {
    background: var(--surface-3);
    color: var(--text);
}

.custom-modal-body {
    padding: 1.5rem;
}

.custom-modal-body .modal-intro {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0 0 1.25rem;
}

.custom-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
    background: var(--surface);
}

.sql-preview {
    background: var(--code-bg);
    color: var(--code-text);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.6;
    padding: 1rem;
    border-radius: var(--r);
    max-height: 180px;
    overflow: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Namespace dropdown */
.namespace-dropdown {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    padding: 0.35rem;
    display: none;
}

.namespace-dropdown.show {
    display: block;
}

.namespace-dropdown .namespace-item {
    padding: 0.5rem 0.7rem;
    cursor: pointer;
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    transition: background var(--dur) var(--ease);
}

.namespace-dropdown .namespace-item:hover,
.namespace-dropdown .namespace-item.highlighted {
    background: var(--surface-3);
}

.namespace-dropdown .namespace-item.selected {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
}

.namespace-dropdown .no-results {
    padding: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.85rem;
}

/* =========================================================
   Tables (users page) + Bootstrap bridges
   ========================================================= */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-hover-bg: var(--surface-2);
    --bs-table-hover-color: var(--text);
    color: var(--text);
    margin-bottom: 0;
}

.table thead th {
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.7rem 0.75rem;
}

.table tbody td {
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0.75rem;
    vertical-align: middle;
}

.table code {
    color: var(--text-2);
    background: var(--surface-3);
    padding: 0.1em 0.4em;
    border-radius: 0.3em;
    font-size: 0.8em;
}

.badge {
    font-weight: 700;
    padding: 0.35rem 0.6rem;
    border-radius: 0.4rem;
}

.badge.bg-primary {
    background: var(--primary) !important;
}

.pagination {
    --bs-pagination-bg: var(--surface);
    --bs-pagination-color: var(--text-2);
    --bs-pagination-border-color: var(--border);
    --bs-pagination-hover-bg: var(--surface-3);
    --bs-pagination-hover-color: var(--text);
    --bs-pagination-hover-border-color: var(--border);
    --bs-pagination-active-bg: var(--primary);
    --bs-pagination-active-border-color: var(--primary);
    --bs-pagination-disabled-bg: var(--surface);
    --bs-pagination-disabled-color: var(--text-muted);
    --bs-pagination-disabled-border-color: var(--border);
    --bs-pagination-focus-box-shadow: 0 0 0 3px var(--ring);
}

.modal {
    --bs-modal-bg: var(--surface);
    --bs-modal-color: var(--text);
    --bs-modal-border-color: var(--border);
    --bs-modal-header-border-color: var(--border);
    --bs-modal-footer-border-color: var(--border);
    --bs-modal-border-radius: var(--r-lg);
}

[data-bs-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.text-muted {
    color: var(--text-muted) !important;
}

.bg-light {
    background-color: var(--surface-2) !important;
}

/* Table loading state (users page) */
.table-responsive {
    position: relative;
    transition: opacity var(--dur) var(--ease);
}

.table-responsive.table-loading {
    pointer-events: none;
}

.table-responsive.table-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    z-index: 10;
}

.table-responsive.table-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 11;
}

#usersTableBody tr {
    animation: fadeIn 0.25s var(--ease);
}

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

/* Detalle de usuario (modal): matriz a la izquierda, GRANT a la derecha */
.grants-roles {
    margin-bottom: 1.25rem;
}

.grants-heading {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.75rem;
}

.grants-heading .icon {
    font-size: 1rem;
}

.grants-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    align-items: stretch;
}

@media (min-width: 992px) {
    .grants-layout {
        grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
        gap: 1.5rem;
    }
}

.grants-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.grants-statements {
    flex: 1;
    background: var(--code-bg);
    border-radius: var(--r);
    padding: 1rem;
    max-height: 420px;
    overflow: auto;
}

.grant-statement {
    margin-bottom: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.55;
    word-break: break-word;
}

.grant-statement:last-child {
    margin-bottom: 0;
}

.grant-statement code {
    color: var(--code-text);
    background: none;
    padding: 0;
    font-size: inherit;
}

.grant-statement.grant-comment {
    color: var(--code-comment);
    font-style: italic;
}

.grants-matrix-wrapper {
    border: 1px solid var(--border);
    border-radius: var(--r);
    max-height: 420px;
    overflow: auto;
}

.grants-matrix {
    font-size: 0.85rem;
    width: 100%;
    margin: 0;
    border-color: var(--border);
}

.grants-matrix thead th {
    background: var(--surface-2);
    font-size: 0.72rem;
    padding: 0.6rem 0.6rem;
    position: sticky;
    top: 0;
    z-index: 1;
}

.grants-matrix thead th abbr {
    text-decoration: none;
    cursor: help;
}

.grants-matrix thead th.priv-col {
    width: 44px;
    min-width: 44px;
    text-align: center;
    color: var(--primary);
}

.grants-matrix tbody td {
    padding: 0.5rem 0.6rem;
    vertical-align: middle;
}

.grants-matrix .priv-cell {
    width: 44px;
    min-width: 44px;
    text-align: center;
}

.grants-matrix .priv-cell.has-priv {
    background: var(--success-soft);
}

.grants-matrix .priv-cell.no-priv {
    background: var(--surface-2);
}

.grants-matrix .priv-cell .icon {
    font-size: 0.95rem;
    color: var(--success);
}

.modal .modal-body {
    padding: 1.5rem;
}


/* =========================================================
   FancySelect (reemplazo visual de <select>)
   ========================================================= */
.fs {
    position: relative;
}

.fs > .fs-native {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    margin: 0;
}

.fs-trigger {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    text-align: left;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: 0.6rem 0.75rem 0.6rem 0.875rem;
    cursor: pointer;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}

[data-bs-theme="dark"] .fs-trigger {
    background: linear-gradient(180deg, var(--surface-3) 0%, var(--surface) 100%);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.fs-trigger:hover:not(:disabled) {
    border-color: var(--text-muted);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

[data-bs-theme="dark"] .fs-trigger:hover:not(:disabled) {
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.fs-trigger:focus-visible,
.fs.is-open .fs-trigger {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring), var(--shadow-sm);
}

.fs-trigger:disabled {
    background: var(--surface-2);
    color: var(--text-muted);
    border-color: var(--border);
    box-shadow: none;
    cursor: not-allowed;
}

.fs-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fs-value.is-placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.fs-chevron {
    color: var(--text-muted);
    font-size: 1.05rem;
    transition: transform var(--dur) var(--ease), color var(--dur) var(--ease);
}

.fs.is-open .fs-chevron {
    transform: rotate(180deg);
    color: var(--primary);
}

.fs-spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.fs.is-loading .fs-spinner {
    display: inline-block;
}

.fs.is-loading .fs-chevron {
    display: none;
}

.fs.is-loading .fs-trigger {
    background-image: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 40%, var(--surface-3) 80%);
    background-size: 200% 100%;
    animation: shimmer 1.2s linear infinite;
    color: var(--text-muted);
    border-color: var(--border);
    box-shadow: none;
}

.fs-menu {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    right: 0;
    z-index: 1100;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.4) inset;
    padding: 0.35rem;
    transform-origin: top center;
    animation: fsIn 160ms var(--ease);
}

[data-bs-theme="dark"] .fs-menu {
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

.fs.fs-up .fs-menu {
    top: auto;
    bottom: calc(100% + 0.4rem);
    transform-origin: bottom center;
}

@keyframes fsIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.985); }
    to { opacity: 1; transform: none; }
}

.fs-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.6rem 0.55rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.fs-search .icon {
    font-size: 0.95rem;
}

.fs-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.875rem;
    padding: 0.25rem 0;
    outline: none;
}

.fs-search-input::placeholder {
    color: var(--text-muted);
}

.fs-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow-y: auto;
    outline: none;
    overscroll-behavior: contain;
}

.fs-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.7rem;
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.fs-option-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fs-option.is-active {
    background: var(--surface-3);
}

.fs-option.is-selected {
    color: var(--primary);
    font-weight: 600;
}

.fs-option.is-selected.is-active {
    background: var(--primary-soft);
}

.fs-check {
    opacity: 0;
    color: var(--primary);
    font-size: 1rem;
    transition: opacity var(--dur) var(--ease);
}

.fs-option.is-selected .fs-check {
    opacity: 1;
}

.fs-empty {
    padding: 0.8rem 0.75rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Los otros desplegables (tablas y namespaces) siguen el mismo lenguaje */
.search-dropdown,
.namespace-dropdown {
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.4) inset;
    transform-origin: top center;
    animation: fsIn 160ms var(--ease);
}

[data-bs-theme="dark"] .search-dropdown,
[data-bs-theme="dark"] .namespace-dropdown {
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

.namespace-dropdown .namespace-item.selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.namespace-dropdown .namespace-item.selected::after {
    content: '✓';
    font-size: 0.8rem;
}

/* =========================================================
   Scrollbars
   ========================================================= */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 5px;
    border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
