/* ==========================================================================
   Lotus-ML Design System (v1)
   - Tokens de color / radio / sombra en :root
   - Componentes .lx-* (sidebar, tarjetas, inputs, botones, badges)
   - Capa de armonización: re-estiliza las utilidades Tailwind que ya usan
     las vistas existentes (tarjetas blancas, inputs, tablas) SIN tocar cada
     plantilla. Todo va con prefijo .lx-main para ganarle a Tailwind CDN.
   ========================================================================== */

:root {
    /* Paleta inspirada en Apple HIG, con el azul de marca Lotus */
    --lx-primary: #2563EB;
    --lx-primary-600: #1D4ED8;
    --lx-primary-400: #3B82F6;
    --lx-primary-50: #EFF5FF;
    --lx-primary-100: #DCE8FE;

    --lx-ink: #1D1D1F;
    --lx-ink-2: #3A3A3C;
    --lx-muted: #6E6E73;
    --lx-subtle: #8E8E93;

    --lx-bg: #F5F5F7;
    --lx-surface: #FFFFFF;
    --lx-surface-2: #F2F2F7;
    --lx-glass: rgba(255, 255, 255, .72);
    --lx-border: rgba(60, 60, 67, .10);
    --lx-border-strong: rgba(60, 60, 67, .18);

    --lx-success: #16A34A;
    --lx-success-50: #EEFBF2;
    --lx-danger: #DC2626;
    --lx-danger-50: #FEF1F1;
    --lx-warning: #D97706;
    --lx-warning-50: #FFF8EB;

    --lx-radius-sm: 10px;
    --lx-radius: 14px;
    --lx-radius-lg: 20px;
    --lx-shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
    --lx-shadow: 0 1px 1px rgba(0, 0, 0, .02), 0 4px 12px rgba(0, 0, 0, .04), 0 16px 32px -16px rgba(0, 0, 0, .08);
    --lx-shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, .25);
    --lx-ring: 0 0 0 4px rgba(37, 99, 235, .16);
    --lx-ease: cubic-bezier(.2, .8, .2, 1);

    --lx-seg-on: #FFFFFF;
    --lx-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", 'Inter', "Segoe UI", Roboto, sans-serif;
}

html, body { font-family: var(--lx-font); }
body.lx-body {
    background: var(--lx-bg);
    color: var(--lx-ink);
    -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.lx-sidebar {
    width: 272px;
    background: var(--lx-glass);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--lx-border);
    border-radius: var(--lx-radius-lg);
    box-shadow: var(--lx-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.lx-brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; border-bottom: 1px solid var(--lx-border); }
.lx-brand img { height: 44px; width: auto; max-width: 104px; object-fit: contain; flex: none; }
/* Logo por defecto de Lotus (sin logo propio): círculo oscuro. El logo de la empresa respeta la forma que eligió. */
.lx-brand img.lx-logo-defecto { width: 44px; border-radius: 999px; object-fit: cover; border: 1px solid var(--lx-border); box-shadow: var(--lx-shadow-sm); background: #0F172A; }
.lx-brand-title { font-weight: 800; font-size: 15px; letter-spacing: -.01em; color: var(--lx-ink); line-height: 1.2; }
.lx-brand-sub { font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--lx-subtle); margin-top: 2px; }

.lx-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
.lx-nav::-webkit-scrollbar { width: 6px; }
.lx-nav::-webkit-scrollbar-thumb { background: #E2E8F0; border-radius: 99px; }

.lx-nav-section {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 10px 8px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
    color: var(--lx-subtle);
}
.lx-pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 2px 8px; border-radius: 999px;
    background: var(--lx-surface-2); color: var(--lx-muted); border: 1px solid var(--lx-border);
}
.lx-pill::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; opacity: .9; }
.lx-pill[data-tone="blue"]   { color: var(--lx-primary); background: var(--lx-primary-50); border-color: var(--lx-primary-100); }
.lx-pill[data-tone="green"]  { color: var(--lx-success); background: var(--lx-success-50); border-color: #DCFCE7; }
.lx-pill[data-tone="teal"]   { color: #0F766E; background: #F0FDFA; border-color: #CCFBF1; }
.lx-pill[data-tone="amber"]  { color: #B45309; background: var(--lx-warning-50); border-color: #FEF3C7; }
.lx-pill[data-tone="rose"]   { color: #BE123C; background: #FFF1F2; border-color: #FFE4E6; }
.lx-pill[data-tone="emerald"]{ color: #047857; background: #ECFDF5; border-color: #D1FAE5; }
.lx-pill[data-tone="red"]    { color: var(--lx-danger); background: var(--lx-danger-50); border-color: #FEE2E2; }

.lx-nav-item {
    --tone: var(--lx-primary);
    --tone-bg: var(--lx-primary-50);
    display: flex; align-items: center; gap: 12px;
    padding: 8px 10px; margin: 2px 0;
    border-radius: 12px;
    color: var(--lx-ink-2);
    font-size: 13.5px; font-weight: 500;
    text-decoration: none;
    transition: background .2s var(--lx-ease), color .2s var(--lx-ease), transform .2s var(--lx-ease);
    width: 100%; text-align: left; background: transparent; border: 0; cursor: pointer;
}
.lx-nav-item[data-tone="teal"]    { --tone: #0F766E; --tone-bg: #F0FDFA; }
.lx-nav-item[data-tone="amber"]   { --tone: #B45309; --tone-bg: #FFFBEB; }
.lx-nav-item[data-tone="rose"]    { --tone: #BE123C; --tone-bg: #FFF1F2; }
.lx-nav-item[data-tone="emerald"] { --tone: #047857; --tone-bg: #ECFDF5; }
.lx-nav-item[data-tone="sky"]     { --tone: #0369A1; --tone-bg: #F0F9FF; }
.lx-nav-item[data-tone="red"]     { --tone: var(--lx-danger); --tone-bg: var(--lx-danger-50); }

.lx-nav-ico {
    flex: none; width: 32px; height: 32px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--lx-surface-2); color: var(--lx-muted);
    border: 1px solid var(--lx-border);
    transition: inherit;
}
.lx-nav-ico svg { width: 17px; height: 17px; }
.lx-nav-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.lx-nav-sub { font-size: 10.5px; font-weight: 500; color: var(--lx-subtle); white-space: normal; }
.lx-nav-item:hover { background: rgba(120, 120, 128, .08); color: var(--lx-ink); }
.lx-nav-item:active { transform: scale(.98); }
.lx-nav-item:hover .lx-nav-ico { color: var(--tone); }
.lx-nav-item.is-active {
    background: var(--tone-bg); color: var(--tone); font-weight: 600;
}
.lx-nav-item.is-active .lx-nav-ico { background: var(--lx-surface); color: var(--tone); border-color: transparent; box-shadow: var(--lx-shadow-sm); }
.lx-nav-item.is-active .lx-nav-sub { color: inherit; opacity: .7; }

.lx-sidebar-foot { padding: 14px; border-top: 1px solid var(--lx-border); }

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */
.lx-topbar {
    display: flex; align-items: center; gap: 12px; justify-content: space-between;
    position: sticky; top: 0; z-index: 30;
    background: var(--lx-glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border: 1px solid var(--lx-border);
    border-radius: var(--lx-radius-lg); box-shadow: var(--lx-shadow-sm);
    padding: 10px 16px; margin-bottom: 24px;
}
.lx-kicker { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--lx-subtle); }
.lx-avatar {
    width: 36px; height: 36px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--lx-primary-50); color: var(--lx-primary); font-weight: 800; font-size: 13px;
    border: 1px solid var(--lx-primary-100);
}
.lx-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--lx-muted); }
.lx-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--lx-success); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.lx-dot.is-off { background: var(--lx-warning); box-shadow: 0 0 0 3px rgba(217,119,6,.15); }

/* --------------------------------------------------------------------------
   Componentes base
   -------------------------------------------------------------------------- */
.lx-page-title { font-size: 30px; font-weight: 700; letter-spacing: -.025em; color: var(--lx-ink); line-height: 1.15; }
.lx-page-sub { color: var(--lx-muted); font-size: 14px; margin-top: 4px; }

.lx-card {
    background: var(--lx-surface); border: 1px solid var(--lx-border);
    border-radius: var(--lx-radius-lg); box-shadow: var(--lx-shadow);
    padding: 24px;
    transition: box-shadow .25s var(--lx-ease), transform .25s var(--lx-ease);
}
.lx-card-hover:hover { box-shadow: var(--lx-shadow-lg); transform: translateY(-2px); }
.lx-card-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; color: var(--lx-ink); margin-bottom: 18px; }
.lx-card-title .lx-ico-chip { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--lx-primary-50); color: var(--lx-primary); }
.lx-panel { background: var(--lx-surface-2); border: 1px solid var(--lx-border); border-radius: var(--lx-radius); padding: 16px; }
.lx-panel[data-tone="blue"]  { background: #F5F8FF; border-color: var(--lx-primary-100); }
.lx-panel[data-tone="amber"] { background: var(--lx-warning-50); border-color: #FDE68A; }
.lx-panel[data-tone="orange"]{ background: #FFF7ED; border-color: #FED7AA; }
.lx-panel[data-tone="indigo"]{ background: #F5F5FF; border-color: #E0E7FF; }

.lx-label { display: block; font-size: 13px; font-weight: 700; color: var(--lx-ink); margin-bottom: 6px; }
.lx-hint { font-size: 11.5px; color: var(--lx-muted); margin-top: 4px; }
.lx-step { display: inline-flex; width: 20px; height: 20px; border-radius: 99px; align-items: center; justify-content: center; background: var(--lx-primary); color: #fff; font-size: 11px; font-weight: 800; margin-right: 8px; }

.lx-input {
    width: 100%; background: var(--lx-surface); color: var(--lx-ink);
    border: 1px solid var(--lx-border-strong); border-radius: 12px;
    padding: 10px 14px; font-size: 14px; line-height: 1.4;
    transition: border-color .15s, box-shadow .15s;
}
.lx-input::placeholder { color: var(--lx-subtle); }
.lx-input:focus { outline: none; border-color: var(--lx-primary-400); box-shadow: var(--lx-ring); }
.lx-input-lg { font-size: 20px; font-weight: 800; padding: 12px 16px; }
.lx-input-group { display: flex; align-items: stretch; }
.lx-input-group .lx-addon { display: inline-flex; align-items: center; padding: 0 14px; background: var(--lx-surface-2); border: 1px solid var(--lx-border-strong); border-right: 0; border-radius: 12px 0 0 12px; color: var(--lx-muted); font-weight: 700; }
.lx-input-group .lx-input { border-radius: 0 12px 12px 0; }

.lx-check { width: 18px; height: 18px; accent-color: var(--lx-primary); cursor: pointer; flex: none; }

.lx-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 700;
    border: 1px solid transparent; cursor: pointer; transition: background .15s, box-shadow .15s, transform .05s;
    text-decoration: none; white-space: nowrap;
}
.lx-btn:active { transform: translateY(1px); }
.lx-btn:focus-visible { outline: none; box-shadow: var(--lx-ring); }
.lx-btn-primary { background: var(--lx-primary); color: #fff; box-shadow: 0 6px 16px -8px rgba(37,99,235,.7); }
.lx-btn-primary:hover { background: var(--lx-primary-600); }
.lx-btn-dark { background: #111827; color: #fff; }
.lx-btn-dark:hover { background: #000; }
.lx-btn-success { background: var(--lx-success); color: #fff; box-shadow: 0 6px 16px -8px rgba(22,163,74,.7); }
.lx-btn-success:hover { background: #15803D; }
.lx-btn-ghost { background: var(--lx-surface); color: var(--lx-ink-2); border-color: var(--lx-border-strong); }
.lx-btn-ghost:hover { background: var(--lx-surface-2); }
.lx-btn-danger { background: var(--lx-danger-50); color: var(--lx-danger); border-color: #FECACA; }
.lx-btn-danger:hover { background: #FEE2E2; }
.lx-btn-block { width: 100%; padding: 13px 18px; font-size: 14px; }

.lx-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.lx-badge-green { background: var(--lx-success-50); color: var(--lx-success); }
.lx-badge-red { background: var(--lx-danger-50); color: var(--lx-danger); }
.lx-badge-blue { background: var(--lx-primary-50); color: var(--lx-primary); }
.lx-badge-amber { background: var(--lx-warning-50); color: var(--lx-warning); }

.lx-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--lx-muted); padding: 40px 16px; gap: 6px; }
.lx-empty svg { width: 56px; height: 56px; color: #CBD5E1; margin-bottom: 8px; }

.lx-line-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--lx-surface); border: 1px solid var(--lx-border); border-radius: 12px; padding: 12px 14px; }
.lx-summary-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--lx-ink-2); padding: 6px 0; }
.lx-summary-total { border-top: 1px dashed var(--lx-border-strong); margin-top: 6px; padding-top: 12px; font-size: 18px; font-weight: 800; color: var(--lx-ink); }

/* --------------------------------------------------------------------------
   Capa de armonización para vistas existentes (Tailwind)
   -------------------------------------------------------------------------- */
.lx-main h1.text-3xl, .lx-main h1.text-4xl, .lx-main h1.text-2xl { letter-spacing: -.02em; color: var(--lx-ink); font-weight: 800; }

/* Tarjetas blancas → radio amplio, borde fino, sombra suave */
.lx-main .bg-white.rounded-xl,
.lx-main .bg-white.rounded-2xl,
.lx-main .bg-white.rounded-lg.shadow,
.lx-main .bg-white.rounded-lg.shadow-sm,
.lx-main .bg-white.rounded-lg.shadow-md,
.lx-main .bg-white.rounded-lg.shadow-lg,
.lx-main .bg-white.rounded.shadow {
    border-radius: var(--lx-radius-lg);
    border: 1px solid var(--lx-border);
    box-shadow: var(--lx-shadow);
}
.lx-main .rounded-lg { border-radius: 12px; }
.lx-main .rounded-xl { border-radius: 16px; }
.lx-main .rounded-2xl { border-radius: 20px; }
.lx-main .rounded:not(.rounded-full) { border-radius: 10px; }

/* Inputs, selects y textareas */
.lx-main input[type="text"],
.lx-main input[type="number"],
.lx-main input[type="date"],
.lx-main input[type="datetime-local"],
.lx-main input[type="month"],
.lx-main input[type="email"],
.lx-main input[type="password"],
.lx-main input[type="search"],
.lx-main input[type="tel"],
.lx-main select:not(.tomselected),
.lx-main textarea {
    border-radius: 12px;
    border-color: var(--lx-border-strong);
    background-color: var(--lx-surface);
    color: var(--lx-ink);
    transition: border-color .15s, box-shadow .15s;
}
.lx-main input[type="text"]:focus,
.lx-main input[type="number"]:focus,
.lx-main input[type="date"]:focus,
.lx-main input[type="month"]:focus,
.lx-main input[type="email"]:focus,
.lx-main input[type="password"]:focus,
.lx-main input[type="search"]:focus,
.lx-main input[type="tel"]:focus,
.lx-main select:focus,
.lx-main textarea:focus {
    outline: none; border-color: var(--lx-primary-400); box-shadow: var(--lx-ring);
}
.lx-main input[type="checkbox"], .lx-main input[type="radio"] { accent-color: var(--lx-primary); }

/* Botones con color sólido */
.lx-main button[class*="bg-"], .lx-main a[class*="bg-"][class*="py-"] { border-radius: 12px; }
.lx-main button[class*="bg-"]:focus-visible { outline: none; box-shadow: var(--lx-ring); }

/* Tablas */
.lx-main table thead th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--lx-muted); font-weight: 700; }
.lx-main table tbody tr { transition: background .12s; }
.lx-main table tbody tr:hover { background: #F8FAFF; }
.lx-main .overflow-x-auto > table { border-collapse: separate; border-spacing: 0; }

/* Tom Select */
.ts-wrapper .ts-control {
    border-radius: 12px !important; border-color: var(--lx-border-strong) !important;
    padding: 10px 14px !important; font-weight: 500; box-shadow: none !important; min-height: 44px;
}
.ts-wrapper.focus .ts-control { border-color: var(--lx-primary-400) !important; box-shadow: var(--lx-ring) !important; }
.ts-dropdown { border-radius: 12px; border-color: var(--lx-border); box-shadow: var(--lx-shadow-lg); overflow: hidden; }
.ts-dropdown .active { background: var(--lx-primary-50); color: var(--lx-primary); }

/* SweetAlert2 */
.swal2-popup { border-radius: 20px !important; font-family: var(--lx-font) !important; }
.swal2-styled.swal2-confirm { background: var(--lx-primary) !important; border-radius: 12px !important; }
.swal2-styled.swal2-cancel { border-radius: 12px !important; }

/* Mensajes flash */
.lx-flash { border-radius: 12px; padding: 12px 16px; font-size: 14px; font-weight: 600; border: 1px solid; }

/* Móvil: sidebar off-canvas */
@media (max-width: 1023px) {
    .lx-aside-wrap { position: fixed; inset: 0 auto 0 0; z-index: 50; padding: 12px; transform: translateX(-105%); transition: transform .2s ease; }
    .lx-aside-wrap.is-open { transform: translateX(0); }
    .lx-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 40; display: none; }
    .lx-backdrop.is-open { display: block; }
}

/* --------------------------------------------------------------------------
   Componentes estilo iOS / macOS
   -------------------------------------------------------------------------- */
/* Switch iOS: <label class="lx-switch"><input type="checkbox"><span></span></label> */
.lx-switch { position: relative; display: inline-flex; flex: none; width: 46px; height: 28px; cursor: pointer; }
.lx-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.lx-switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(120,120,128,.24); transition: background .25s var(--lx-ease); }
.lx-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 999px; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.18), 0 0 1px rgba(0,0,0,.1); transition: transform .25s var(--lx-ease); }
.lx-switch input:checked + span { background: #34C759; }
.lx-switch input:checked + span::after { transform: translateX(18px); }
.lx-switch input:focus-visible + span { box-shadow: var(--lx-ring); }
.lx-switch.is-sm { width: 38px; height: 23px; }
.lx-switch.is-sm span::after { width: 19px; height: 19px; }
.lx-switch.is-sm input:checked + span::after { transform: translateX(15px); }

/* Control segmentado (pestañas) */
.lx-segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: rgba(118,118,128,.12); overflow-x: auto; max-width: 100%; }
.lx-segmented { scrollbar-width: none; }
.lx-segmented::-webkit-scrollbar { display: none; }
.lx-segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--lx-ink-2); cursor: pointer; white-space: nowrap; transition: background .2s var(--lx-ease), box-shadow .2s var(--lx-ease); }
.lx-segmented a { display: inline-flex; align-items: center; padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--lx-ink-2); text-decoration: none; white-space: nowrap; }
.lx-segmented a[aria-selected="true"] { background: var(--lx-seg-on); color: var(--lx-ink); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.04); }
.lx-segmented button[aria-selected="true"] { background: var(--lx-seg-on); color: var(--lx-ink); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.04); }
.lx-segmented label { display: inline-flex; align-items: center; padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--lx-ink-2); white-space: nowrap; transition: background .2s var(--lx-ease); }
.lx-segmented label[aria-selected="true"] { background: var(--lx-seg-on); color: var(--lx-ink); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.04); }
.lx-tabpanel[hidden] { display: none !important; }
.lx-tabpanel { animation: lxFade .25s var(--lx-ease); }
@keyframes lxFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Lista agrupada estilo Ajustes de iOS */
.lx-group { background: var(--lx-surface); border: 1px solid var(--lx-border); border-radius: 16px; overflow: hidden; }
.lx-group-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--lx-muted); margin: 0 4px 8px; }
.lx-row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; min-height: 52px; }
.lx-row + .lx-row { border-top: 1px solid var(--lx-border); }
.lx-row-icon { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.lx-row-icon svg { width: 17px; height: 17px; }
.lx-row-main { flex: 1; min-width: 0; }
.lx-row-title { font-size: 14.5px; font-weight: 500; color: var(--lx-ink); }
.lx-row-sub { font-size: 12.5px; color: var(--lx-muted); margin-top: 1px; }

/* Chat estilo iMessage */
.lx-chat { display: flex; flex-direction: column; gap: 10px; }
.lx-bubble { max-width: 82%; padding: 10px 14px; border-radius: 18px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; animation: lxFade .25s var(--lx-ease); }
.lx-bubble.is-user { align-self: flex-end; background: var(--lx-primary); color: #fff; border-bottom-right-radius: 6px; }
.lx-bubble.is-ai { align-self: flex-start; background: var(--lx-surface-2); color: var(--lx-ink); border-bottom-left-radius: 6px; }
.lx-bubble.is-error { align-self: flex-start; background: var(--lx-danger-50); color: #991B1B; }
.lx-typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.lx-typing i { width: 7px; height: 7px; border-radius: 99px; background: var(--lx-subtle); animation: lxDot 1.2s infinite ease-in-out; }
.lx-typing i:nth-child(2) { animation-delay: .15s; }
.lx-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes lxDot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.lx-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--lx-surface-2); color: var(--lx-ink-2); border: 1px solid var(--lx-border); cursor: pointer; transition: background .2s var(--lx-ease); }
.lx-chip:hover { background: var(--lx-primary-50); color: var(--lx-primary); }
.lx-composer { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; border-radius: 999px; border: 1px solid var(--lx-border-strong); background: var(--lx-surface); }
.lx-composer:focus-within { border-color: var(--lx-primary-400); box-shadow: var(--lx-ring); }
.lx-composer input { flex: 1; border: 0 !important; outline: none; box-shadow: none !important; background: transparent !important; font-size: 14px; padding: 6px 0; }
.lx-send { width: 34px; height: 34px; border-radius: 999px; border: 0; background: var(--lx-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.lx-send:disabled { opacity: .4; cursor: default; }

/* --------------------------------------------------------------------------
   Formularios: input con ícono, stepper, cabecera de página y barra de filtros
   -------------------------------------------------------------------------- */
.lx-field { position: relative; display: block; }
.lx-field > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--lx-subtle); pointer-events: none; }
.lx-field > .lx-input, .lx-field > input, .lx-field > select { padding-left: 40px !important; }
.lx-field.is-textarea > svg { top: 14px; transform: none; }
.lx-field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--lx-ink-2); margin: 0 0 6px 2px; }
.lx-form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.lx-form-grid .lx-span-2 { grid-column: span 2; }
@media (max-width: 640px) { .lx-form-grid .lx-span-2 { grid-column: auto; } }

.lx-stepper { display: flex; flex-direction: column; gap: 0; }
.lx-step-item { position: relative; padding-left: 44px; padding-bottom: 22px; }
.lx-step-item:last-child { padding-bottom: 0; }
.lx-step-item::before { content: ""; position: absolute; left: 14px; top: 30px; bottom: 0; width: 2px; background: var(--lx-border); }
.lx-step-item:last-child::before { display: none; }
.lx-step-num { position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; background: var(--lx-primary-50); color: var(--lx-primary); border: 1px solid var(--lx-primary-100); }
.lx-step-title { font-size: 15px; font-weight: 600; color: var(--lx-ink); line-height: 30px; margin-bottom: 10px; }

.lx-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.lx-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 12px; border-radius: 16px; background: var(--lx-surface); border: 1px solid var(--lx-border); box-shadow: var(--lx-shadow-sm); }
.lx-toolbar > * { flex: 1 1 150px; }
.lx-toolbar > .lx-grow { flex: 3 1 260px; }
.lx-toolbar > .lx-btn { flex: 0 0 auto; }
.lx-stat { padding: 18px 20px; }
.lx-stat .lx-kicker { margin-bottom: 6px; }
.lx-stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--lx-ink); font-variant-numeric: tabular-nums; }
.lx-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.lx-table th { text-align: left; padding: 10px 14px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--lx-muted); font-weight: 600; background: var(--lx-surface-2); }
.lx-table th:first-child { border-radius: 10px 0 0 10px; }
.lx-table th:last-child { border-radius: 0 10px 10px 0; }
.lx-table td { padding: 12px 14px; border-bottom: 1px solid var(--lx-border); color: var(--lx-ink-2); vertical-align: top; }
.lx-table tr:last-child td { border-bottom: 0; }
.lx-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Modo Legacy (lo activa el SuperAdmin por empresa): sidebar oscuro clásico
   -------------------------------------------------------------------------- */
.lx-legacy { --lx-bg: #EEF2F7; }
.lx-legacy .lx-sidebar { background: #0F172A; border-color: #0F172A; -webkit-backdrop-filter: none; backdrop-filter: none; }
.lx-legacy .lx-brand { border-color: rgba(255,255,255,.08); }
.lx-legacy .lx-brand-title { color: #fff; }
.lx-legacy .lx-brand-sub, .lx-legacy .lx-nav-section { color: rgba(255,255,255,.45); }
.lx-legacy .lx-nav-item { color: rgba(255,255,255,.78); }
.lx-legacy .lx-nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.lx-legacy .lx-nav-ico { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.08); color: rgba(255,255,255,.75); }
.lx-legacy .lx-nav-sub { color: rgba(255,255,255,.45); }
.lx-legacy .lx-nav-item.is-active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 #fff; }
.lx-legacy .lx-nav-item.is-active .lx-nav-ico { background: rgba(255,255,255,.18); color: #fff; }
.lx-legacy .lx-sidebar-foot { border-color: rgba(255,255,255,.08); }
.lx-legacy .lx-pill { background: rgba(255,255,255,.08); border-color: transparent; }
.lx-legacy .lx-topbar { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }


/* ==========================================================================
   MODO OSCURO (html[data-theme="dark"]) — elegante, estilo macOS
   Se activa desde el botón sol/luna del encabezado (preferencia por dispositivo).
   ========================================================================== */
html[data-theme="dark"] {
    color-scheme: dark;
    --lx-primary: #3B82F6;
    --lx-primary-600: #2563EB;
    --lx-primary-400: #60A5FA;
    --lx-primary-50: rgba(59, 130, 246, .14);
    --lx-primary-100: rgba(59, 130, 246, .28);
    --lx-ink: #F5F5F7;
    --lx-ink-2: #D1D1D6;
    --lx-muted: #98989D;
    --lx-subtle: #6E6E73;
    --lx-bg: #0A0A0C;
    --lx-surface: #151517;
    --lx-surface-2: #1E1E21;
    --lx-glass: rgba(21, 21, 23, .72);
    --lx-border: rgba(255, 255, 255, .08);
    --lx-border-strong: rgba(255, 255, 255, .15);
    --lx-success: #30D158;
    --lx-success-50: rgba(48, 209, 88, .13);
    --lx-danger: #FF453A;
    --lx-danger-50: rgba(255, 69, 58, .13);
    --lx-warning: #FF9F0A;
    --lx-warning-50: rgba(255, 159, 10, .13);
    --lx-shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --lx-shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    --lx-shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .7);
    --lx-ring: 0 0 0 4px rgba(59, 130, 246, .3);
    --lx-seg-on: #3A3A3C;
}
html[data-theme="dark"] body.lx-body { background:
    radial-gradient(1000px 600px at 100% -10%, rgba(59,130,246,.08), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(139,92,246,.07), transparent 60%), var(--lx-bg); }
html[data-theme="dark"] .lx-segmented { background: rgba(118, 118, 128, .24); }
html[data-theme="dark"] .lx-switch span { background: rgba(120, 120, 128, .36); }
html[data-theme="dark"] .lx-btn-dark { background: #F5F5F7; color: #0A0A0C; }
html[data-theme="dark"] .lx-btn-dark:hover { background: #fff; }
html[data-theme="dark"] .lx-flash.bg-emerald-50 { background: var(--lx-success-50) !important; color: #A7F3D0 !important; border-color: rgba(48,209,88,.3) !important; }
html[data-theme="dark"] .lx-flash.bg-red-50 { background: var(--lx-danger-50) !important; color: #FECACA !important; border-color: rgba(255,69,58,.3) !important; }
html[data-theme="dark"] .lx-flash.bg-slate-50 { background: var(--lx-surface-2) !important; color: var(--lx-ink-2) !important; border-color: var(--lx-border) !important; }
html[data-theme="dark"] .lx-panel[data-tone="blue"] { background: rgba(59,130,246,.08); border-color: rgba(59,130,246,.25); }
html[data-theme="dark"] .lx-panel[data-tone="amber"] { background: rgba(255,159,10,.08); border-color: rgba(255,159,10,.25); }
html[data-theme="dark"] .lx-panel[data-tone="orange"] { background: rgba(255,159,10,.08); border-color: rgba(255,159,10,.25); }
html[data-theme="dark"] .lx-panel[data-tone="indigo"] { background: rgba(99,102,241,.08); border-color: rgba(99,102,241,.25); }
html[data-theme="dark"] .lx-table tbody tr:hover, html[data-theme="dark"] .lx-main table tbody tr:hover { background: rgba(255,255,255,.03); }
html[data-theme="dark"] .ts-wrapper .ts-control, html[data-theme="dark"] .ts-dropdown { background: var(--lx-surface) !important; color: var(--lx-ink) !important; }
html[data-theme="dark"] .ts-dropdown .option { color: var(--lx-ink-2); }
html[data-theme="dark"] .swal2-popup { background: var(--lx-surface) !important; color: var(--lx-ink) !important; }
html[data-theme="dark"] dialog { background: var(--lx-surface); color: var(--lx-ink); }

/* Vistas antiguas con utilidades Tailwind claras → paleta oscura */
html[data-theme="dark"] .lx-main .bg-white { background-color: var(--lx-surface) !important; }
html[data-theme="dark"] .lx-main :is(.bg-gray-50, .bg-slate-50, .bg-gray-100, .bg-slate-100, .bg-zinc-50) { background-color: var(--lx-surface-2) !important; }
html[data-theme="dark"] .lx-main :is(.bg-blue-50, .bg-indigo-50, .bg-sky-50) { background-color: rgba(59,130,246,.10) !important; }
html[data-theme="dark"] .lx-main :is(.bg-green-50, .bg-emerald-50, .bg-green-100, .bg-emerald-100) { background-color: rgba(48,209,88,.10) !important; }
html[data-theme="dark"] .lx-main :is(.bg-red-50, .bg-rose-50, .bg-red-100) { background-color: rgba(255,69,58,.10) !important; }
html[data-theme="dark"] .lx-main :is(.bg-amber-50, .bg-yellow-50, .bg-orange-50, .bg-amber-100) { background-color: rgba(255,159,10,.10) !important; }
html[data-theme="dark"] .lx-main :is(.bg-purple-50, .bg-violet-50) { background-color: rgba(139,92,246,.10) !important; }
html[data-theme="dark"] .lx-main :is(.text-gray-900, .text-gray-800, .text-slate-900, .text-slate-800, .text-black) { color: var(--lx-ink) !important; }
html[data-theme="dark"] .lx-main :is(.text-gray-700, .text-slate-700, .text-gray-600, .text-slate-600) { color: var(--lx-ink-2) !important; }
html[data-theme="dark"] .lx-main :is(.text-gray-500, .text-slate-500, .text-gray-400, .text-slate-400) { color: var(--lx-muted) !important; }
html[data-theme="dark"] .lx-main :is(.border-gray-100, .border-gray-200, .border-gray-300, .border-slate-100, .border-slate-200, .border-slate-300) { border-color: var(--lx-border) !important; }
html[data-theme="dark"] .lx-main :is(.divide-gray-100, .divide-gray-200, .divide-slate-50, .divide-slate-100) > * + * { border-color: var(--lx-border) !important; }
html[data-theme="dark"] .lx-main :is(.text-blue-600, .text-blue-700, .text-blue-800) { color: #60A5FA !important; }
html[data-theme="dark"] .lx-main :is(.text-green-600, .text-green-700, .text-emerald-600, .text-emerald-700) { color: #30D158 !important; }
html[data-theme="dark"] .lx-main :is(.text-red-600, .text-red-700, .text-rose-700) { color: #FF6961 !important; }
html[data-theme="dark"] .lx-main input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
html[data-theme="dark"] .lx-main select, html[data-theme="dark"] .lx-main textarea { background-color: var(--lx-surface-2); color: var(--lx-ink); border-color: var(--lx-border-strong); }
html[data-theme="dark"] .lx-main input::placeholder, html[data-theme="dark"] .lx-main textarea::placeholder { color: var(--lx-subtle); }

/* Botón de tema (sol / luna) */
.lx-theme-btn { width: 36px; height: 36px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--lx-border); background: var(--lx-surface); color: var(--lx-ink-2); cursor: pointer; transition: background .2s var(--lx-ease), transform .2s var(--lx-ease); }
.lx-theme-btn:hover { background: var(--lx-surface-2); }
.lx-theme-btn:active { transform: scale(.94); }
.lx-theme-btn .ico-sol { display: none; }
html[data-theme="dark"] .lx-theme-btn .ico-sol { display: inline; }
html[data-theme="dark"] .lx-theme-btn .ico-luna { display: none; }

/* Preferencias de usuario */
.lx-compact .lx-nav-sub { display: none; }
.lx-compact .lx-nav-item { padding-top: 6px; padding-bottom: 6px; }
.lx-calm *, .lx-calm *::before, .lx-calm *::after { animation: none !important; transition: none !important; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
    .lx-aside-wrap, .lx-topbar, .lx-backdrop { display: none !important; }
    body.lx-body { background: #fff; }
}

/* ===== Visor de documentos (static/js/lx-visor.js): facturas, remisiones y soportes ===== */
.lx-visor { width: min(96vw, 980px); height: min(92vh, 1100px); max-width: none; max-height: none; padding: 0; border: 0;
    border-radius: 24px; background: var(--lx-surface); color: var(--lx-ink); box-shadow: var(--lx-shadow-lg);
    display: none; flex-direction: column; overflow: hidden; }
.lx-visor[open] { display: flex; animation: lxVisorIn .22s cubic-bezier(.2,.8,.2,1); }
.lx-visor::backdrop { background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.lx-visor-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--lx-border); }
.lx-visor-ico { width: 38px; height: 38px; flex: none; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--lx-primary-50); color: var(--lx-primary); }
.lx-visor-ico svg, .lx-visor-imprimir svg { width: 18px; height: 18px; }
.lx-visor-tit { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lx-visor-tit strong { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.lx-visor-tit span { font-size: 12px; color: var(--lx-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lx-visor-cerrar { width: 38px; padding: 8px 0 !important; }
.lx-visor-body { flex: 1; position: relative; background: var(--lx-surface-2); }
.lx-visor-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; opacity: 0; transition: opacity .2s; }
.lx-visor-body iframe.listo { opacity: 1; }
.lx-visor-cargando { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--lx-muted); }
html.lx-visor-abierto { overflow: hidden; }
@keyframes lxVisorIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@media (max-width: 640px) {
    .lx-visor { width: 100vw; height: 100dvh; border-radius: 0; }
    .lx-visor-aparte { display: none; }
}

/* ===== Editor de imágenes (static/js/lx-recorte.js) ===== */
.lx-recorte { width: min(96vw, 640px); max-height: 94vh; padding: 0; border: 0; border-radius: 24px; background: var(--lx-surface);
    color: var(--lx-ink); box-shadow: var(--lx-shadow-lg); overflow-y: auto; }
.lx-recorte[open] { animation: lxVisorIn .22s cubic-bezier(.2,.8,.2,1); }
.lx-recorte::backdrop { background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.lx-recorte-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 10px; }
.lx-recorte-head strong { display: block; font-size: 17px; letter-spacing: -.01em; }
.lx-recorte-head span { display: block; font-size: 12.5px; color: var(--lx-muted); margin-top: 2px; }
.lx-recorte-x { width: 38px; padding: 8px 0 !important; }
.lx-recorte-formas { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 20px 14px; }
.lx-recorte-formas .lx-chip[aria-checked="true"] { background: var(--lx-primary); color: #fff; border-color: var(--lx-primary); }
.lx-recorte-ico { display: inline-block; border: 2px solid currentColor; opacity: .85; }
.lx-recorte-ico-circulo { width: 13px; height: 13px; border-radius: 999px; }
.lx-recorte-ico-cuadrado { width: 12px; height: 12px; border-radius: 3px; }
.lx-recorte-ico-horizontal { width: 15px; height: 11px; border-radius: 3px; }
.lx-recorte-ico-panoramica { width: 17px; height: 10px; border-radius: 3px; }
.lx-recorte-ico-vertical { width: 10px; height: 14px; border-radius: 3px; }
.lx-recorte-ico-original { width: 14px; height: 12px; border-radius: 3px; border-style: dashed; }
.lx-recorte-stage { margin: 0 20px; border-radius: 16px; overflow: hidden;
    background: repeating-conic-gradient(#e5e7eb 0% 25%, #f8fafc 0% 50%) 50% / 20px 20px; }
.lx-recorte-stage canvas { display: block; width: 100%; height: auto; cursor: grab; touch-action: none; }
.lx-recorte-stage canvas.arrastrando { cursor: grabbing; }
.lx-recorte-ctrl { display: flex; align-items: center; gap: 8px; padding: 14px 20px 4px; flex-wrap: wrap; }
.lx-recorte-ctrl input[type=range] { flex: 1 1 160px; accent-color: var(--lx-primary); }
.lx-recorte-ctrl .lx-btn { padding: 8px 12px; }
.lx-recorte-pie { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px 20px; }
html[data-theme="dark"] .lx-recorte-stage { background: repeating-conic-gradient(#1f2937 0% 25%, #111827 0% 50%) 50% / 20px 20px; }
