/* ============================================================
   CRM — sistema de diseño (réplica del estilo Trinova, genérico)
   Para la marca del cliente: cambiar SOLO las variables de :root.
   ============================================================ */
:root {
    --background: #f1f5f9;
    --foreground: #1e293b;

    /* Marca (índigo genérico) */
    --primary: #6366f1;
    --primary-light: #c7d2fe;
    --primary-dark: #4f46e5;
    --dark: #1e293b;
    --sidebar: #1e1b4b;

    /* Neutros / estados */
    --surface: #ffffff;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;

    --slate-50: #f8fafc; --slate-100: #f1f5f9; --slate-200: #e2e8f0; --slate-300: #cbd5e1; --slate-400: #94a3b8;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / .25);
    --ring: 0 0 0 2px var(--primary-light);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font: 14px/20px Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 300; background: #fff; padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--primary-dark); outline-offset: 2px; }

/* ============================================================
   SHELL: sidebar + área de trabajo
   ============================================================ */
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50;
    display: flex; flex-direction: column; width: 230px; height: 100vh; flex-shrink: 0;
    background: var(--sidebar); color: rgb(255 255 255 / .9);
    transform: translateX(-100%); transition: transform .2s ease-out;
}
body.sidebar-open .sidebar { transform: translateX(0); }
.sidebar-backdrop {
    position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .5);
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
.sidebar-close {
    position: absolute; right: 12px; top: 16px; display: grid; place-items: center;
    width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: rgb(255 255 255 / .6);
}
.sidebar-close:hover { background: rgb(255 255 255 / .1); color: #fff; }
.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 20px; }
.sidebar-tagline { margin: -12px 0 16px; padding: 0 24px; font-size: 11px; font-style: italic; color: rgb(255 255 255 / .4); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0 12px; }
.nav-section + .nav-section { margin-top: 16px; }
.nav-title { margin: 0 0 4px; padding: 0 12px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: rgb(255 255 255 / .4); }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
    font-size: 14px; color: rgb(255 255 255 / .7); transition: background-color .15s, color .15s;
}
.nav-link:hover { background: rgb(255 255 255 / .05); color: #fff; }
.nav-link.is-active { background: color-mix(in srgb, var(--primary) 22%, transparent); color: #c7d2fe; font-weight: 500; }
.nav-link .label { flex: 1; }
.nav-badge {
    display: flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 999px; background: var(--error); color: #fff; font-size: 11px; font-weight: 700;
}
.sidebar-user { border-top: 1px solid rgb(255 255 255 / .1); padding: 12px; }
.sidebar-user-link { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; }
.sidebar-user-link:hover { background: rgb(255 255 255 / .05); }
.sidebar-user .user-name { margin: 0; font-size: 14px; font-weight: 500; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { margin: 0; font-size: 11px; color: rgb(255 255 255 / .5); }
.logout-btn {
    margin-top: 4px; display: flex; width: 100%; align-items: center; gap: 12px; padding: 8px 12px;
    border: 0; border-radius: 8px; background: none; font-size: 14px; color: rgb(255 255 255 / .6); text-align: left;
}
.logout-btn:hover { background: rgb(255 255 255 / .05); color: #fff; }

.work { position: relative; display: flex; min-width: 0; flex: 1; flex-direction: column; overflow: hidden; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    border-bottom: 1px solid var(--border); background: #fff; padding: 12px 16px;
}
.topbar-left { display: flex; min-width: 0; align-items: center; gap: 12px; }
.topbar-right { display: flex; flex-shrink: 0; align-items: center; gap: 8px; }
.menu-btn {
    display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
    border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--dark);
}
.menu-btn:hover { background: var(--slate-100); }
.greet-title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.greet-sub { margin: 0; display: none; gap: 8px; font-size: 14px; color: var(--text-secondary); }
.greet-sub .date { text-transform: capitalize; }
.greet-sub .sep { color: var(--border); }
.greet-sub .time { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--primary-dark); }
.zoom { display: none; align-items: center; gap: 4px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.zoom-btn { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 4px; background: none; color: var(--text-secondary); }
.zoom-btn:hover { background: var(--slate-100); }
.zoom-btn:disabled { opacity: .4; cursor: default; }
.zoom-pct { min-width: 42px; border: 0; border-radius: 4px; background: none; padding: 0 4px; font-size: 12px; font-weight: 500; color: var(--dark); }
.zoom-pct:hover { background: var(--slate-100); }
.topbar .btn-new .label { display: none; }

.work-area { flex: 1; overflow-y: auto; background: var(--background); }
.work-inner { display: flex; height: 100%; min-height: 0; flex-direction: column; padding: 16px; }

@media (min-width: 640px) {
    .greet-sub { display: flex; }
    .zoom { display: flex; }
    .topbar .btn-new .label { display: inline; }
}
@media (min-width: 1024px) {
    .sidebar { position: static; transform: none; }
    .sidebar-backdrop, .sidebar-close, .menu-btn { display: none; }
    .topbar { padding: 16px 32px; }
    .topbar-right { gap: 12px; }
    .greet-title { font-size: 18px; line-height: 28px; }
    .work-inner { padding: 32px; }
}

/* ============================================================
   FEEDBACK DE NAVEGACIÓN: barra superior + splash + guardando
   ============================================================ */
.nav-progress { pointer-events: none; position: fixed; inset: 0 0 auto 0; z-index: 100; height: 5px; }
.nav-progress-bar {
    height: 100%; width: 0;
    background: linear-gradient(to right, var(--primary-light), var(--primary), var(--primary-dark));
    box-shadow: 0 0 10px color-mix(in srgb, var(--primary-dark) 70%, transparent);
    transition: width .2s cubic-bezier(0, 0, .2, 1);
}

.nav-splash {
    position: absolute; inset: 0; z-index: 50;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
    background: rgb(241 245 249 / .6);
    -webkit-backdrop-filter: blur(12px) saturate(1.5); backdrop-filter: blur(12px) saturate(1.5);
    animation: nav-splash-fade-in .28s ease-out both;
}
/* Splash de entrada (pantalla completa, una vez por sesión) */
.app-splash {
    position: fixed; inset: 0; z-index: 150; display: none;
    flex-direction: column; align-items: center; justify-content: center; gap: 28px;
    background: radial-gradient(circle at 50% 40%, #ffffff 0%, var(--background) 70%);
    transition: opacity .4s ease, visibility .4s ease;
}
html.show-splash .app-splash { display: flex; animation: app-splash-failsafe .4s ease 3s forwards; }
/* Respaldo: si el JS no carga, igual se va a los 3 s. */
@keyframes app-splash-failsafe { to { opacity: 0; visibility: hidden; } }
.app-splash.is-leaving { opacity: 0; visibility: hidden; }
.app-splash .splash-word { font-size: 36px; line-height: 40px; }
.app-splash .splash-ring { width: 64px; height: 64px; }

.splash-pop { display: flex; flex-direction: column; align-items: center; gap: 10px; animation: nav-splash-pop .32s ease-out both; }
.splash-mark {
    display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
}
.splash-logo { display: flex; align-items: center; gap: 14px; }
.splash-ring { position: relative; display: grid; place-items: center; width: 54px; height: 54px; color: var(--dark); flex-shrink: 0; }
.splash-ring::before {
    content: ""; position: absolute; inset: 0; border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--primary-dark) 20%, transparent); border-top-color: var(--primary-dark);
    animation: spin 1s linear infinite;
}
.splash-word { font-size: 30px; line-height: 36px; font-weight: 700; letter-spacing: -.025em; }
.splash-word .a { color: var(--dark); }
.splash-word .b { color: var(--primary-dark); }
.splash-tagline { margin-top: -4px; font-size: 12px; font-style: italic; color: var(--text-secondary); }
.splash-track { position: relative; width: 224px; height: 5px; overflow: hidden; border-radius: 999px; background: rgb(148 163 184 / .2); }
.splash-bar {
    position: absolute; top: 0; bottom: 0; width: 45%; border-radius: 999px;
    background: linear-gradient(to right, var(--primary), var(--primary-dark));
    animation: nav-splash-slide 1.25s cubic-bezier(.65, 0, .35, 1) infinite;
}
@keyframes nav-splash-slide { 0% { left: -45%; } 100% { left: 100%; } }
@keyframes nav-splash-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nav-splash-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

.saving {
    position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--sidebar) 60%, transparent);
    -webkit-backdrop-filter: blur(1px); backdrop-filter: blur(1px);
}
.saving-card { display: flex; width: 280px; flex-direction: column; align-items: center; gap: 16px; padding: 32px; border-radius: 22px; background: #fff; box-shadow: var(--shadow-2xl); text-align: center; }
.saving-spin { width: 48px; height: 48px; border-radius: 50%; border: 4px solid var(--primary-light); border-top-color: var(--primary-dark); animation: spin 1s linear infinite; }
.saving-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--dark); }
.saving-sub { margin: 4px 0 0; font-size: 12px; color: var(--text-secondary); }

/* ============================================================
   MARCA (logo genérico)
   ============================================================ */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
}
.brand-word { font-size: 20px; line-height: 28px; font-weight: 700; letter-spacing: -.025em; }
.brand-a { color: var(--dark); }
.brand-b { color: var(--primary-dark); }
.brand-on-dark .brand-a { color: #fff; }
.brand-on-dark .brand-b { color: var(--primary-light); }
.brand-lg .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
.brand-lg .brand-word { font-size: 26px; line-height: 32px; }

/* ============================================================
   PÁGINAS
   ============================================================ */
.page { display: flex; flex-direction: column; gap: 24px; }
.page-fixed { display: flex; height: 100%; min-height: 0; flex-direction: column; gap: 20px; }
.page-fixed > .fixed { flex-shrink: 0; }
.scroll-area { min-height: 0; flex: 1; overflow: auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.page-title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; color: var(--dark); }
.page-sub { margin: 0; font-size: 14px; color: var(--text-secondary); }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.back-link { font-size: 14px; color: var(--primary-dark); }
.back-link:hover { text-decoration: underline; }
.narrow { width: 100%; max-width: 768px; margin: 0 auto; }
.narrow-sm { width: 100%; max-width: 672px; margin: 0 auto; }

/* --- Botones --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
    font-size: 14px; font-weight: 600; color: var(--dark); white-space: nowrap; transition: background-color .15s, opacity .15s;
}
.btn:hover { background: var(--slate-50); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { border-color: var(--primary-dark); background: var(--primary-dark); color: #fff; }
.btn-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-outline { color: var(--primary-dark); }
.btn-muted { font-weight: 500; color: var(--text-secondary); padding: 8px 12px; }
.btn-muted:hover { background: var(--slate-100); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-wa { border-color: #25d366; background: #25d366; color: #fff; }
.btn-wa:hover { background: #25d366; opacity: .9; }
.btn-danger { border-color: var(--error); background: var(--error); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-outline { border-color: #fecaca; color: var(--error); }
.btn-danger-outline:hover { background: #fef2f2; }
.btn-success { border-color: var(--success); background: var(--success); color: #fff; }
.btn .spin-on-load { transition: transform .2s; }
.btn.is-loading .spin-on-load { animation: spin 1s linear infinite; }

/* --- Tarjetas --- */
.card { border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 20px; box-shadow: var(--shadow-sm); }
.card-sm { padding: 16px; }
.card-lg { padding: 24px; }
.card-title { margin: 0 0 12px; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--dark); }
.card-title-sm { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--dark); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head .card-title, .card-head .card-title-sm { margin: 0; }
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.kpi { border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 16px; box-shadow: var(--shadow-sm); }
.kpi-label { margin: 0; font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.kpi-value { margin: 6px 0 0; font-size: 20px; line-height: 28px; font-weight: 700; color: var(--dark); }
@media (min-width: 768px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpi-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } .kpi-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* --- Hero "Requieren tu atención" --- */
.hero { border-radius: 16px; padding: 24px; color: #fff; background: linear-gradient(to bottom right, var(--primary), var(--primary-dark)); box-shadow: var(--shadow-sm); }
.hero-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero-title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; }
.hero-sub { margin: 4px 0 0; color: rgb(255 255 255 / .8); }
.hero-link { border-radius: 8px; background: rgb(255 255 255 / .2); padding: 8px 16px; font-size: 14px; font-weight: 500; backdrop-filter: blur(8px); }
.hero-link:hover { background: rgb(255 255 255 / .3); }
.hero-pills { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.hero-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; background: rgb(255 255 255 / .15); padding: 6px 14px; font-size: 14px; backdrop-filter: blur(8px); }
.hero-pill:hover { background: rgb(255 255 255 / .25); }
.hero-pill strong { font-weight: 600; }
.hero-pill span { color: rgb(255 255 255 / .8); }

/* --- Formularios --- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 14px; font-weight: 500; color: var(--dark); }
.label-mini { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); }
.input, .select, .textarea {
    width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #fff;
    padding: 8px 12px; font-size: 14px; color: var(--dark); outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary-dark); box-shadow: var(--ring); }
.input-lg { padding: 10px 12px; }
.select {
    appearance: none; -webkit-appearance: none; padding: 10px 36px 10px 12px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .6rem center;
}
.select-sm { padding: 6px 30px 6px 10px; font-size: 12px; font-weight: 500; color: var(--text-secondary); background-position: right .4rem center; background-size: 16px; }
.textarea { resize: vertical; min-height: 64px; }
.fieldset { margin: 0; border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 20px; }
.legend { padding: 0 8px; font-size: 14px; font-weight: 600; color: var(--dark); }
.form { display: flex; flex-direction: column; gap: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.col-span-2 { grid-column: 1 / -1; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; }
.hint { margin: 0; font-size: 12px; color: var(--text-secondary); }
.readonly { border: 1px solid var(--border); border-radius: 8px; background: var(--slate-50); padding: 8px 12px; font-size: 14px; color: var(--text-secondary); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary-dark); }

/* --- Filtros (desktop + móvil) --- */
.filters-desktop { display: none; flex-direction: column; gap: 12px; }
.filter-row { display: flex; gap: 12px; align-items: flex-end; }
.filter-row > .field { flex: 1; }
.filter-row > .field.grow { flex: 1.5; }
.filter-admin { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; border: 1px dashed var(--border); border-radius: 8px; background: rgb(248 250 252 / .6); padding: 12px; }
.filter-admin > .field { flex: 1 1 160px; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--slate-400); pointer-events: none; }
.search-wrap .input { padding-left: 34px; }
.filters-mobile { display: flex; flex-direction: column; gap: 8px; }
.filters-mobile-row { display: flex; gap: 8px; }
.filters-mobile-row form { flex: 1; }
.filter-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 14px;
    border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: var(--shadow-sm);
    font-size: 14px; font-weight: 600; color: var(--dark);
}
.filter-btn.is-active { border-color: var(--primary-dark); background: color-mix(in srgb, var(--primary-light) 30%, white); color: var(--primary-dark); }
.count-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 999px; background: var(--primary-dark); color: #fff; font-size: 11px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip-filter {
    display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 4px 6px 4px 10px;
    border: 1px solid var(--primary-light); border-radius: 999px; background: color-mix(in srgb, var(--primary-light) 25%, white);
    font-size: 12px; font-weight: 500; color: var(--primary-dark);
}
.chip-filter .txt { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-sm { font-size: 12px; font-weight: 500; color: var(--text-secondary); text-decoration: underline; }
@media (min-width: 640px) { .filters-desktop { display: flex; } .filters-mobile { display: none; } }

/* --- Bottom sheet --- */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: color-mix(in srgb, var(--dark) 50%, transparent); backdrop-filter: blur(2px); animation: sheet-fade-in .2s ease-out both; }
.sheet-panel {
    position: absolute; inset: auto 0 0 0; display: flex; max-height: 88vh; flex-direction: column;
    border-radius: 24px 24px 0 0; background: #fff; box-shadow: var(--shadow-2xl);
    animation: sheet-slide-up .28s cubic-bezier(.22, 1, .36, 1) both;
}
.sheet-handle { display: flex; justify-content: center; padding: 12px 0 4px; }
.sheet-handle span { width: 40px; height: 6px; border-radius: 999px; background: var(--slate-300); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 4px 20px 12px; }
.sheet-head h3 { margin: 0; flex: 1; font-size: 16px; font-weight: 600; color: var(--dark); }
.sheet-close { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--text-secondary); }
.sheet-close:hover { background: var(--slate-100); }
.sheet-body { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; padding: 4px 20px 8px; }
.sheet-foot { display: flex; gap: 8px; border-top: 1px solid var(--border); padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.sheet-foot .btn { border-radius: 12px; padding: 12px 16px; }
@keyframes sheet-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
body.sheet-open { overflow: hidden; }

/* --- Resumen colapsable (móvil) --- */
.collapse-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 8px 12px; font-size: 14px; font-weight: 500; color: var(--dark); }
.collapse-toggle svg { transition: transform .2s; }
.collapse-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.collapse-body { display: none; margin-top: 12px; }
.collapse-body.is-open { display: block; }
@media (min-width: 640px) { .collapse-toggle { display: none; } .collapse-body { display: block; margin-top: 0; } }

/* --- Tablas (encabezado fijo) --- */
.table-wrap { min-height: 0; flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); }
.tbl { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 14px; }
.tbl thead { position: sticky; top: 0; z-index: 10; }
.tbl th { background: var(--slate-50); border-bottom: 1px solid var(--border); padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .025em; color: var(--text-secondary); white-space: nowrap; }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--slate-50); }
.tbl .num { text-align: right; }
.tbl-name { font-weight: 500; color: var(--dark); }
.tbl-name:hover { color: var(--primary-dark); }
.tbl-check { width: 40px; padding-right: 0 !important; }
.tbl-check input, .card-check input { width: 16px; height: 16px; accent-color: var(--primary-dark); cursor: pointer; }
.only-desktop { display: none; }
.only-mobile { display: flex; }
@media (min-width: 1024px) { .only-desktop { display: block; } .only-desktop.table-wrap { display: block; } .only-mobile { display: none !important; } }

/* --- Tarjeta de lead (móvil) --- */
.mobile-list { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: 12px; overflow-y: auto; }
.lead-card { position: relative; border: 1px solid var(--border); border-radius: 16px; background: #fff; padding: 16px 16px 16px 24px; box-shadow: var(--shadow-sm); }
.lead-card::before { content: ""; position: absolute; top: 12px; bottom: 12px; left: 0; width: 4px; border-radius: 999px; background: var(--c, var(--primary)); }
.lead-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.lead-card-name { font-size: 16px; font-weight: 600; color: var(--dark); }
.lead-card-meta { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--text-secondary); }
.lead-card-meta span { display: inline-flex; align-items: center; gap: 6px; }
.lead-card-foot { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; font-size: 12px; color: var(--text-secondary); }
.lead-card-actions { margin-top: 12px; display: flex; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.lead-card-actions .btn { flex: 1; padding: 8px 12px; }
.card-check { display: flex; align-items: flex-start; gap: 8px; }
.card-check > input { margin-top: 18px; }
.card-check > .lead-card { flex: 1; min-width: 0; }

/* --- Badges y avatar --- */
.badge {
    --c: #64748b;
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
    font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap;
    color: var(--c); background: color-mix(in srgb, var(--c) 13%, white);
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.badge-strong { font-weight: 600; }
.avatar { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; line-height: 1; user-select: none; }
.avatar-empty { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1px dashed #fca5a5; border-radius: 50%; font-size: 10px; color: #f87171; }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.who .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unassigned { color: #ef4444; font-weight: 500; }
.pill-muted { display: inline-flex; border-radius: 999px; background: var(--slate-100); padding: 4px 12px; font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.pill-amber { display: inline-flex; border-radius: 999px; background: #fef3c7; padding: 2px 8px; font-size: 10px; font-weight: 600; color: #b45309; }

/* --- Detalle del lead --- */
.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.detail-name { margin: 0; font-size: 24px; line-height: 32px; font-weight: 700; color: var(--dark); }
.detail-actions { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.detail-actions .btn { padding: 6px 12px; font-weight: 500; }
.detail-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.detail-main, .detail-aside { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 1024px) { .detail-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
.dl-rows { display: flex; flex-direction: column; gap: 12px; margin: 0; font-size: 14px; }
.dl-row { display: flex; justify-content: space-between; gap: 12px; }
.dl-row dt { flex-shrink: 0; color: var(--text-secondary); }
.dl-row dd { margin: 0; min-width: 0; text-align: right; font-weight: 500; color: var(--dark); word-break: break-word; }
.dl-stack { display: flex; flex-direction: column; gap: 4px; }
.dl-stack dt { color: var(--text-secondary); }
.dl-stack dd { margin: 0; white-space: pre-line; word-break: break-word; font-weight: 500; color: var(--dark); }
.dl-sep { border-top: 1px solid var(--border); padding-top: 12px; }
.status-select {
    --c: #64748b;
    appearance: none; -webkit-appearance: none; cursor: pointer;
    border: 1px solid var(--c); border-radius: 8px; padding: 6px 12px; font-size: 14px; font-weight: 600;
    color: var(--c); background: color-mix(in srgb, var(--c) 7%, white); outline: none;
}
.status-select option { color: var(--dark); background: #fff; }
.link-muted { font-size: 14px; color: var(--text-secondary); }
.link-muted:hover { color: var(--primary-dark); text-decoration: underline; }
.link-primary { font-size: 12px; font-weight: 500; color: var(--primary-dark); }
.link-primary:hover { text-decoration: underline; }
.danger-zone { border-color: #fecaca; }
.danger-zone h3 { color: var(--error); margin: 0 0 4px; font-size: 14px; }

/* --- Composer de notas --- */
.composer { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 12px; }
.type-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.type-chip { border: 0; border-radius: 999px; background: var(--slate-100); padding: 4px 10px; font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.type-chip:hover { background: var(--slate-200); }
.type-chip.is-active { background: var(--primary-dark); color: #fff; }
.composer-row { display: flex; gap: 8px; }
.composer-row .input { flex: 1; }
.attach-preview { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--slate-50); padding: 8px; }
.attach-preview img { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; background: #fff; }
.attach-info { display: flex; min-width: 0; flex: 1; flex-direction: column; font-size: 12px; color: var(--dark); }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-img { margin-top: 8px; display: inline-block; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.tl-img img { display: block; max-height: 224px; width: auto; max-width: 100%; object-fit: contain; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.file-ic { display: grid; flex-shrink: 0; color: var(--primary-dark); }
.btn-attach { padding: 8px 11px; color: var(--text-secondary); }
.btn-attach:hover { color: var(--primary-dark); background: color-mix(in srgb, var(--primary-light) 25%, white); border-color: var(--primary-light); }
.file-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; color: var(--primary-dark); }
.file-name:hover { text-decoration: underline; }
.file-del { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--text-secondary); }
.file-del:hover { background: #fef2f2; color: var(--error); }
.file-input { font-size: 13px; color: var(--text-secondary); max-width: 100%; }
.file-input::file-selector-button { margin-right: 10px; border: 0; border-radius: 8px; padding: 8px 12px; font: inherit; font-weight: 600; cursor: pointer; background: color-mix(in srgb, var(--primary-light) 45%, white); color: var(--primary-dark); }

/* --- Timeline --- */
.tl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.tl-item { display: flex; gap: 12px; }
.tl-marker { display: flex; flex-direction: column; align-items: center; }
.tl-dot { margin-top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--slate-300); }
.tl-dot.is-note { background: var(--primary-dark); }
.tl-line { margin-top: 4px; width: 1px; flex: 1; background: var(--border); }
.tl-body { flex: 1; min-width: 0; padding-bottom: 4px; }
.tl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tl-label { border-radius: 999px; background: var(--slate-100); padding: 2px 8px; font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.tl-label.is-note { background: color-mix(in srgb, var(--primary-light) 40%, white); color: var(--primary-dark); }
.tl-who { font-size: 12px; color: var(--text-secondary); }
.tl-text { margin: 4px 0 0; font-size: 14px; color: var(--dark); white-space: pre-line; word-break: break-word; }

/* --- Pipeline (kanban) --- */
.board { min-height: 0; flex: 1; overflow: auto; }
.board-cols { display: flex; gap: 16px; }
.kcol { display: flex; width: 288px; flex-shrink: 0; flex-direction: column; }
.kcol-head { position: sticky; top: 0; z-index: 10; background: var(--background); padding: 2px 0 4px; }
.kcol-title { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.kcol-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.kcol-name { font-size: 14px; font-weight: 600; color: var(--dark); }
.kcol-count { border-radius: 999px; background: var(--slate-200); padding: 0 6px; font-size: 12px; color: var(--text-secondary); }
.kcol-total { margin: 0; padding: 0 4px; font-size: 11px; color: var(--text-secondary); }
.kcol-body { display: flex; flex-direction: column; gap: 8px; border-radius: 8px; background: rgb(241 245 249 / .6); padding: 8px; }
.kcol-empty { padding: 24px 0; text-align: center; font-size: 12px; color: var(--text-secondary); }
.kcol-more { padding: 6px 0; text-align: center; font-size: 12px; color: var(--primary-dark); }
.kcard { overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: var(--shadow-sm); }
.kcard-stripe { height: 6px; background: var(--c); }
.kcard-body { padding: 12px; }
.kcard-name { display: block; font-size: 14px; font-weight: 500; color: var(--dark); }
.kcard-name:hover { color: var(--primary-dark); }
.kcard-company { margin: 0; font-size: 12px; color: var(--text-secondary); }
.kcard-who { margin-top: 10px; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; color: var(--dark); }
.kcard-row { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kcard-value { font-size: 12px; font-weight: 600; color: var(--dark); }
.kcard-days { font-size: 11px; color: var(--text-secondary); }
.kcard-move { appearance: auto; border: 1px solid var(--border); border-radius: 4px; background: var(--slate-50); padding: 4px; font-size: 11px; color: var(--text-secondary); max-width: 130px; }

/* --- Tareas --- */
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task-check { display: grid; place-items: center; width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; border: 2px solid var(--border); border-radius: 4px; background: #fff; padding: 0; color: #fff; }
.task-check:hover { border-color: var(--success); }
.task-check.is-done { border-color: var(--success); background: var(--success); }
.task-title { margin: 0; font-size: 14px; font-weight: 500; color: var(--dark); }
.task-desc { margin: 2px 0 0; font-size: 12px; color: var(--text-secondary); }
.task-meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--text-secondary); }
.task-meta a { color: var(--primary-dark); }
.task-meta a:hover { text-decoration: underline; }
.task-meta .is-overdue { font-weight: 500; color: var(--error); }
.task.is-done { opacity: .6; padding: 10px 0; }
.task.is-done .task-title { text-decoration: line-through; }

/* --- Barra de asignación en bulk --- */
.bulk-bar { position: fixed; inset: auto 0 16px 0; z-index: 40; display: flex; justify-content: center; padding: 0 16px; pointer-events: none; }
.bulk-box { pointer-events: auto; display: flex; width: 100%; max-width: 672px; flex-wrap: wrap; align-items: center; gap: 8px; border-radius: 12px; background: var(--dark); padding: 12px 16px; color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; }
.bulk-box .grow { flex: 1; }
.bulk-box .select { width: auto; padding-top: 6px; padding-bottom: 6px; }
.bulk-box .btn-light { border: 0; border-radius: 8px; background: var(--primary-light); padding: 7px 12px; font-weight: 600; color: var(--sidebar); }
.bulk-box .lnk { border: 0; background: none; color: #cbd5e1; font-size: 12px; text-decoration: underline; }
.has-bulk { padding-bottom: 88px; }

/* --- Reportes --- */
.rbars { display: flex; flex-direction: column; gap: 8px; }
.rbar { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.rbar-label { flex-shrink: 0; width: 120px; color: var(--dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rbar-track { position: relative; flex: 1; height: 24px; border-radius: 6px; background: var(--slate-100); overflow: hidden; }
.rbar-fill { display: flex; align-items: center; justify-content: flex-end; height: 100%; min-width: 28px; border-radius: 6px; padding-right: 8px; background: var(--c, var(--primary-dark)); color: #fff; font-weight: 600; }
.rbar-extra { flex-shrink: 0; width: 64px; text-align: right; color: var(--success); font-weight: 600; }
.grid-cards { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 1024px) { .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* --- Equipo --- */
.team-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .team-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.team-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 16px; box-shadow: var(--shadow-sm); }
.team-card:hover { border-color: var(--primary-light); }
.team-card.is-inactive { opacity: .55; }
.team-info { min-width: 0; flex: 1; }
.team-name { margin: 0; font-weight: 600; color: var(--dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-mail { margin: 0 0 6px; font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch span { display: block; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--dark); }
.swatch input:focus-visible + span { outline: 2px solid var(--primary-dark); outline-offset: 2px; }

/* --- Alertas / vacíos --- */
.alert { border: 1px solid; border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.alert-success { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.alert-error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.alert-info { border-color: var(--primary-light); background: color-mix(in srgb, var(--primary-light) 25%, white); color: var(--primary-dark); }
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.empty { border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 40px 16px; text-align: center; font-size: 14px; color: var(--text-secondary); }
.empty-inline { margin: 0; font-size: 14px; color: var(--text-secondary); }
.placeholder { margin-top: 24px; border: 1px dashed var(--border); border-radius: 12px; background: rgb(255 255 255 / .5); padding: 40px; text-align: center; font-size: 14px; color: var(--text-secondary); }

/* --- Actividad reciente --- */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.activity li:last-child { border-bottom: 0; }
.activity .dot { margin-top: 6px; width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--primary); }
.activity .txt { flex: 1; min-width: 0; font-size: 14px; color: var(--dark); }
.activity .txt a { font-weight: 500; color: var(--primary-dark); }
.activity .sub { margin: 2px 0 0; font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity .when { flex-shrink: 0; font-size: 12px; color: var(--text-secondary); }

/* --- Paginación --- */
.pager { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--text-secondary); }
.pager .btns { display: flex; gap: 8px; }

/* --- Login --- */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; background: var(--sidebar); }
.login-card { width: 100%; max-width: 384px; border-radius: 16px; background: #fff; padding: 32px; box-shadow: var(--shadow-xl); }
.login-head { margin-bottom: 32px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.login-head p { margin: 0; font-size: 14px; color: var(--text-secondary); }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .btn { margin-top: 8px; }

/* --- Utilidades --- */
.muted { color: var(--text-secondary); }
.xs { font-size: 12px; line-height: 16px; }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-error { color: var(--error); }
.text-success { color: var(--success); }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.m0 { margin: 0; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 639px) { .hide-sm { display: none !important; } }
@media (min-width: 640px) { .show-sm-only { display: none !important; } }
