/* ==========================================================================
   Vendedor24h — Sistema de diseño
   Tu vendedor que nunca duerme.
   ========================================================================== */

/* ----- 1. Tokens ---------------------------------------------------------- */
:root {
    /* Marca — verde ventas / WhatsApp / éxito */
    --brand-50:  #e9faf1;
    --brand-100: #c9f2dd;
    --brand-200: #97e6c0;
    --brand-300: #5cd49e;
    --brand-400: #24bd7d;
    --brand-500: #07a866;
    --brand-600: #018a54;
    --brand-700: #026e46;
    --brand-800: #04573a;
    --brand-900: #063d2a;
    --brand-mint: #2fd39b; /* verde del logotipo Vendedor24h */

    /* Verde WhatsApp — acento SOLO en superficies de WhatsApp (chat, conexión, estado) */
    --wa:     #20c15c;
    --wa-50:  #e6f8ee;
    --wa-100: #c3edd3;
    --wa-700: #0e7a3f;

    /* Acento — IA / inteligencia */
    --ai-400: #8b7bfb;
    --ai-500: #7059f3;
    --ai-600: #5b40df;
    --ai-50:  #efecfe;

    /* Neutros */
    --ink-900: #0b1512;
    --ink-800: #14211d;
    --ink-700: #1e2b27;
    --slate-900: #0f172a;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50:  #f8fafc;

    /* Semánticos */
    --success: #0f9d58;
    --warning: #d98e04;
    --danger:  #e0483d;
    --info:    #2f7de1;
    --success-bg: #e6f6ec;
    --warning-bg: #fdf3e0;
    --danger-bg:  #fdecea;
    --info-bg:    #e9f2fd;

    /* Superficies */
    --bg:        #f5f7f9;
    --surface:   #ffffff;
    --surface-2: #fbfcfd;
    --border:    #e6eaee;
    --border-strong: #d5dbe1;

    /* Texto */
    --text:      #16211d;
    --text-soft: #55636b;
    --text-mute: #8a97a0;
    --text-invert: #ffffff;

    /* Sidebar */
    --nav-bg:    #0b1512;
    --nav-bg-2:  #0f1d18;
    --nav-item:  #9db2ab;
    --nav-item-hover: #ffffff;
    --nav-active-bg: rgba(7, 168, 102, .16);
    --nav-active-fg: #4fd39c;

    /* Sombras */
    --shadow-xs: 0 1px 2px rgba(16, 33, 27, .06);
    --shadow-sm: 0 1px 3px rgba(16, 33, 27, .08), 0 1px 2px rgba(16, 33, 27, .04);
    --shadow-md: 0 4px 12px rgba(16, 33, 27, .08), 0 2px 4px rgba(16, 33, 27, .04);
    --shadow-lg: 0 12px 32px rgba(16, 33, 27, .12), 0 4px 8px rgba(16, 33, 27, .06);
    --shadow-pop: 0 8px 28px rgba(11, 21, 18, .16);

    /* Radios */
    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-full: 999px;

    /* Layout */
    --nav-w: 252px;
    --nav-w-collapsed: 76px;
    --topbar-h: 64px;
    --content-max: 1180px;

    --ease: cubic-bezier(.4, 0, .2, 1);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ----- 2. Reset --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; font-feature-settings: "cv11", "ss01"; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
h1, h2, h3, h4 { font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-200); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

/* ----- 3. Layout / shell --------------------------------------------------- */
.app {
    display: grid;
    grid-template-columns: var(--nav-w) 1fr;
    min-height: 100vh;
    transition: grid-template-columns .22s var(--ease);
}
.app.is-collapsed { grid-template-columns: var(--nav-w-collapsed) 1fr; }

.main { display: flex; flex-direction: column; min-width: 0; }
.content {
    flex: 1;
    padding: 28px clamp(18px, 4vw, 40px) 60px;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
}

/* ----- 4. Sidebar ------------------------------------------------------- */
.nav {
    background: linear-gradient(180deg, var(--nav-bg-2), var(--nav-bg));
    color: var(--nav-item);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    border-right: 1px solid rgba(255, 255, 255, .05);
}
.nav__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px 14px 18px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
}
.nav__brand-link { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; color: #fff; }
.nav__logo { display: flex; flex-shrink: 0; color: #fff; }
.nav__logo svg { display: block; }
.nav__title { font-weight: 700; font-size: 14.5px; letter-spacing: -.01em; overflow: hidden; }
.nav__title small { display: block; font-weight: 500; font-size: 11px; color: var(--nav-item); letter-spacing: .02em; margin-top: 1px; }

/* Logotipo de texto (Vendedor + 24h en verde) */
.brand-word { font-weight: 700; letter-spacing: -.015em; white-space: nowrap; }
.brand-word b { color: var(--brand-mint, #2fd39b); font-weight: 800; }

.nav__collapse {
    width: 28px; height: 28px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 8px;
    color: var(--nav-item);
    background: rgba(255, 255, 255, .05);
    transition: background .14s var(--ease), color .14s var(--ease), transform .22s var(--ease);
}
.nav__collapse:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nav__collapse svg { transform: rotate(180deg); transition: transform .22s var(--ease); }
.is-collapsed .nav__collapse svg { transform: rotate(0deg); }

.nav__scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 12px 12px; }
.nav__scroll::-webkit-scrollbar { width: 6px; }
.nav__scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border: 0; }

.nav__section {
    margin-top: 16px; padding: 0 10px 6px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: #5d726b;
    transition: opacity .12s var(--ease);
}
.nav__section span { display: block; overflow: hidden; text-overflow: ellipsis; }

.nav__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 11px;
    border-radius: 10px;
    color: var(--nav-item);
    font-weight: 550;
    font-size: 13.5px;
    white-space: nowrap;
    position: relative;
    transition: background .14s var(--ease), color .14s var(--ease);
}
.nav__link svg { width: 19px; height: 19px; flex-shrink: 0; stroke-width: 1.9; }
.nav__link span { overflow: hidden; text-overflow: ellipsis; }
.nav__link:hover { background: rgba(255, 255, 255, .06); color: var(--nav-item-hover); }
.nav__link.is-active { background: var(--nav-active-bg); color: var(--nav-active-fg); font-weight: 650; }
.nav__link.is-active::before {
    content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--brand-400);
}
.nav__link .nav__badge {
    margin-left: auto;
    background: var(--brand-500); color: #fff;
    font-size: 10.5px; font-weight: 700;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px; display: grid; place-items: center;
}

/* ── Estado contraído (escritorio) ── */
.is-collapsed .nav__link { justify-content: center; padding: 11px 10px; }
.is-collapsed .nav__link > span,
.is-collapsed .nav__title { display: none; }
.is-collapsed .nav__brand-link { flex: 0; }
.is-collapsed .nav__collapse { display: none; }
.is-collapsed .nav__badge {
    position: absolute; top: 3px; right: 4px; margin: 0;
    min-width: 15px; height: 15px; font-size: 9.5px; padding: 0 3px;
    border: 2px solid var(--nav-bg);
}
.is-collapsed .nav__brand { justify-content: center; padding: 16px 0 14px; }
.is-collapsed .nav__section { height: 1px; margin: 14px 12px 8px; padding: 0; background: rgba(255,255,255,.08); overflow: hidden; }
.is-collapsed .nav__section span { display: none; }
.is-collapsed .nav__vendor { justify-content: center; padding: 10px 0; }
.is-collapsed .nav__vendor span:last-child { display: none; }
.is-collapsed .nav__foot { padding: 10px 12px; }

.nav__foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .06); }
.nav__vendor {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 11px; border-radius: 10px;
    background: rgba(255, 255, 255, .04);
    font-size: 12.5px; color: #cdd9d4;
    white-space: nowrap; overflow: hidden;
}
.nav__pulse { width: 8px; height: 8px; border-radius: 999px; background: var(--wa); flex-shrink: 0; position: relative; }
.nav__pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 999px; background: var(--wa); opacity: .4; animation: pulse 2s var(--ease) infinite; }
.nav__pulse.is-off { background: var(--slate-500); }
.nav__pulse.is-off::after { display: none; }
@keyframes pulse { 0% { transform: scale(.8); opacity: .5; } 70% { transform: scale(2.2); opacity: 0; } 100% { opacity: 0; } }

/* ----- 5. Topbar ------------------------------------------------------- */
.topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 clamp(16px, 3vw, 28px);
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar__toggle, .topbar__icon-btn {
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center; color: var(--text-soft);
    transition: background .14s var(--ease), color .14s var(--ease);
}
.topbar__toggle:hover, .topbar__icon-btn:hover { background: var(--slate-100); color: var(--text); }
.topbar__search {
    flex: 1; max-width: 420px;
    display: flex; align-items: center; gap: 9px;
    padding: 8px 13px; border-radius: var(--r-full);
    background: var(--slate-100);
    border: 1px solid transparent;
    color: var(--text-mute);
    transition: border-color .14s var(--ease), background .14s var(--ease);
}
.topbar__search:focus-within { background: #fff; border-color: var(--brand-300); box-shadow: 0 0 0 4px var(--brand-50); }
.topbar__search input { flex: 1; border: 0; background: none; outline: 0; color: var(--text); font-size: 13px; }
.topbar__search kbd {
    font-family: var(--font); font-size: 10.5px; font-weight: 600; color: var(--text-mute);
    background: #fff; border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}
.topbar__spacer { flex: 1; }
.topbar__right { display: flex; align-items: center; gap: 8px; }

.avatar {
    width: 34px; height: 34px; border-radius: 999px;
    background: linear-gradient(140deg, var(--ai-400), var(--brand-500));
    color: #fff; font-weight: 700; font-size: 12.5px;
    display: grid; place-items: center; flex-shrink: 0;
    text-transform: uppercase;
}
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--lg { width: 44px; height: 44px; font-size: 15px; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown__menu {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
    padding: 6px;
    z-index: 50;
    opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
    transition: opacity .13s var(--ease), transform .13s var(--ease);
}
.dropdown.is-open .dropdown__menu { opacity: 1; transform: none; pointer-events: auto; }
.dropdown__item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--r-sm);
    font-size: 13px; color: var(--text-soft); width: 100%;
}
.dropdown__item:hover { background: var(--slate-100); color: var(--text); }
.dropdown__item svg { width: 16px; height: 16px; }
.dropdown__item.is-danger { color: var(--danger); }
.dropdown__divider { height: 1px; background: var(--border); margin: 5px 2px; }
.dropdown__label { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-mute); }

/* Notificaciones (campana) */
.notif__bell { position: relative; }
.notif__dot {
    position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
    display: grid; place-items: center; border-radius: 999px;
    background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 1;
    border: 2px solid var(--surface);
}
.notif__menu { width: 340px; padding: 0; overflow: hidden; }
.notif__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700;
}
.notif__readall { font-size: 11.5px; font-weight: 600; color: var(--brand-600); }
.notif__readall:hover { text-decoration: underline; }
.notif__list { max-height: 380px; overflow-y: auto; }
.notif__empty { padding: 26px 14px; text-align: center; font-size: 12.5px; color: var(--text-mute); }
.notif__item {
    display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border);
    transition: background .1s var(--ease);
}
.notif__item:last-child { border-bottom: 0; }
.notif__item:hover { background: var(--slate-50); }
.notif__item.is-unread { background: var(--brand-50); }
.notif__item.is-unread:hover { background: var(--brand-100, #d9f2e6); }
.notif__ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.notif__ic--handoff { background: var(--ai-50); color: var(--ai-600); }
.notif__ic--opportunity { background: #fdf0d8; color: #b7791f; }
.notif__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif__body b { font-size: 12.5px; color: var(--text); }
.notif__body span { font-size: 12px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif__body time { font-size: 11px; color: var(--text-mute); margin-top: 1px; }

/* ----- 6. Page header ------------------------------------------------------ */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head__text { flex: 1; min-width: 220px; }
.page-title { font-size: 21px; font-weight: 680; letter-spacing: -.02em; }
.page-subtitle { color: var(--text-soft); font-size: 13.5px; margin-top: 3px; }
.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.breadcrumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-mute); margin-bottom: 10px; }
.breadcrumbs a:hover { color: var(--text-soft); }

/* ----- 7. Buttons ------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 15px;
    border-radius: var(--r-sm);
    font-weight: 600; font-size: 13px; white-space: nowrap;
    border: 1px solid transparent;
    transition: transform .08s var(--ease), background .14s var(--ease), box-shadow .14s var(--ease), border-color .14s var(--ease);
    user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; stroke-width: 2; }
.btn--primary { background: linear-gradient(180deg, var(--brand-500), var(--brand-600)); color: #fff; box-shadow: 0 1px 2px rgba(4, 87, 58, .3), inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn--primary:hover { box-shadow: 0 4px 14px rgba(7, 168, 102, .35); }
.btn--secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { border-color: var(--slate-400); background: var(--surface-2); }
.btn--ghost { color: var(--text-soft); }
.btn--ghost:hover { background: var(--slate-100); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #c93b31; }
.btn--ai { background: linear-gradient(180deg, var(--ai-500), var(--ai-600)); color: #fff; }
.btn--ai:hover { box-shadow: 0 4px 14px rgba(112, 89, 243, .35); }
.btn--sm { padding: 6px 11px; font-size: 12px; border-radius: var(--r-xs); }
.btn--lg { padding: 12px 20px; font-size: 14px; }
.btn--block { width: 100%; }
.btn--icon { padding: 9px; }
.btn:disabled, .btn.is-loading { opacity: .6; pointer-events: none; }
.btn.is-loading { position: relative; color: transparent; }
.btn.is-loading::after {
    content: ""; position: absolute; width: 15px; height: 15px;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 999px;
    animation: spin .6s linear infinite; color: #fff;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- 8. Cards -------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
}
.card__head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.card__title { font-size: 14.5px; font-weight: 640; }
.card__body { padding: 18px; }
.card__foot { padding: 13px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); }
.card__head .btn { margin-left: auto; }

/* ----- 9. Stat tiles ---------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: box-shadow .16s var(--ease), transform .16s var(--ease);
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat__icon {
    width: 34px; height: 34px; border-radius: 9px;
    display: grid; place-items: center; margin-bottom: 12px;
    background: var(--brand-50); color: var(--brand-600);
}
.stat__icon svg { width: 18px; height: 18px; }
.stat__icon--ai { background: var(--ai-50); color: var(--ai-600); }
.stat__icon--warn { background: var(--warning-bg); color: var(--warning); }
.stat__icon--info { background: var(--info-bg); color: var(--info); }
.stat__label { font-size: 12.5px; color: var(--text-soft); font-weight: 550; }
.stat__value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat__delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; margin-top: 7px; }
.stat__delta.is-up { color: var(--success); }
.stat__delta.is-down { color: var(--danger); }
.stat__delta.is-flat { color: var(--text-mute); }

/* ----- 10. Badges ----------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: var(--r-full);
    font-size: 11.5px; font-weight: 600; line-height: 1.4;
    background: var(--slate-100); color: var(--slate-600);
    white-space: nowrap;
}
.badge__dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge--success { background: var(--success-bg); color: #0b7c44; }
.badge--wa { background: var(--wa-50); color: var(--wa-700); }
.badge--wa .badge__dot { background: var(--wa); }

/* ── Selector de vendedor por número (Mi Vendedor / Probar) ──── */
.vendor-switch {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 12px 14px; margin-bottom: 16px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-xs);
}
.vendor-switch__label {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 650; color: var(--text-mute);
    text-transform: uppercase; letter-spacing: .04em;
}
.vendor-switch__pills { display: flex; gap: 8px; flex-wrap: wrap; }
.vendor-pill {
    display: inline-flex; flex-direction: column; gap: 1px;
    padding: 7px 13px; border-radius: 10px;
    border: 1.5px solid var(--border); background: var(--surface-2);
    text-decoration: none; transition: border-color .12s, background .12s;
}
.vendor-pill:hover { border-color: var(--wa-100); }
.vendor-pill.is-active { border-color: var(--wa); background: var(--wa-50); }
.vendor-pill__name { font-size: 13px; font-weight: 650; color: var(--text); }
.vendor-pill__tag { font-size: 10.5px; color: var(--text-mute); }
.vendor-pill__tag--own { color: var(--wa-700); font-weight: 600; }
.badge--warning { background: var(--warning-bg); color: #a66a00; }
.badge--danger  { background: var(--danger-bg); color: #b93c32; }
.badge--info    { background: var(--info-bg); color: #1e63b8; }
.badge--ai      { background: var(--ai-50); color: var(--ai-600); }
.badge--neutral { background: var(--slate-100); color: var(--slate-600); }
.badge--outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-soft); }

/* ----- 11. Tables ---------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-sm); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
    text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase;
    color: var(--text-mute); padding: 11px 16px; background: var(--surface-2);
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-clickable { cursor: pointer; }
.table__primary { font-weight: 600; color: var(--text); }
.table__muted { color: var(--text-mute); }
.table__cell-flex { display: flex; align-items: center; gap: 10px; }

/* .table--stack: en pantallas chicas cada fila se vuelve una tarjeta legible */
@media (max-width: 720px) {
    .table--stack thead { display: none; }
    .table--stack tbody tr { display: block; padding: 14px; }
    .table--stack tbody tr + tr { border-top: 6px solid var(--surface-2); }
    .table--stack tbody td {
        display: flex; align-items: center; justify-content: space-between; gap: 16px;
        padding: 5px 0; border: 0; font-size: 13px;
    }
    .table--stack tbody td::before {
        content: attr(data-label);
        flex-shrink: 0; font-size: 11px; font-weight: 650;
        text-transform: uppercase; letter-spacing: .03em; color: var(--text-mute);
    }
    .table--stack tbody td:not([data-label])::before { display: none; }
    .table--stack tbody td > * { text-align: right; }

    /* Celda "nombre": encabezado de la tarjeta, a lo ancho */
    .table--stack tbody td.cell-stack-title {
        display: block; padding: 0 0 9px;
        margin-bottom: 8px; border-bottom: 1px solid var(--border);
    }
    .table--stack tbody td.cell-stack-title > * { text-align: left; }
    .table--stack .cell-name__title { font-size: 14px; }

    /* Celda de acciones: botones siempre visibles, a la derecha */
    .table--stack tbody td.cell-stack-actions { padding-top: 10px; justify-content: flex-end; }
    .table--stack .row-actions { opacity: 1; }
    /* Acciones redundantes en móvil (la tarjeta entera ya es un enlace) */
    .table--stack tbody td.cell-actions-optional { display: none; }
}

/* ----- 12. Forms ---------------------------------------------------- */
.field { margin-bottom: 16px; }
.field__label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field__hint { font-size: 12px; color: var(--text-mute); margin-top: 5px; }
.field__error { font-size: 12px; color: var(--danger); margin-top: 5px; font-weight: 500; }
.input, .textarea, .select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--slate-400); }
.input:focus, .textarea:focus, .select:focus { outline: 0; border-color: var(--brand-400); box-shadow: 0 0 0 4px var(--brand-50); }
.input.has-error, .textarea.has-error, .select.has-error { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-bg); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--text-mute); }
.input-group { display: flex; }
.input-group .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group__addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--slate-100); color: var(--text-mute); font-size: 13px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

/* Toggle */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track { width: 38px; height: 22px; border-radius: 999px; background: var(--slate-300); position: relative; transition: background .16s var(--ease); flex-shrink: 0; }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 999px; background: #fff; box-shadow: var(--shadow-sm); transition: transform .16s var(--ease); }
.switch input:checked + .switch__track { background: var(--brand-500); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 4px var(--brand-50); }

/* Choice chips */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.choice {
    border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    padding: 13px; cursor: pointer; text-align: center; font-weight: 550; font-size: 13px;
    transition: border-color .14s var(--ease), background .14s var(--ease);
}
.choice:hover { border-color: var(--brand-300); background: var(--brand-50); }
.choice.is-selected { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); box-shadow: 0 0 0 3px var(--brand-50); }

/* ----- 13. Flash / alerts ------------------------------------------- */
.alert {
    display: flex; gap: 11px; align-items: flex-start;
    padding: 12px 15px; border-radius: var(--r-sm);
    font-size: 13px; border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert--success { background: var(--success-bg); color: #0b7c44; border-color: #bfe6cd; }
.alert--danger  { background: var(--danger-bg); color: #b93c32; border-color: #f3c9c4; }
.alert--warning { background: var(--warning-bg); color: #a66a00; border-color: #f0dcb4; }
.alert--info    { background: var(--info-bg); color: #1e63b8; border-color: #c6ddf7; }

/* ----- 14. Toasts -------------------------------------------------- */
.toast-stack { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
    display: flex; align-items: center; gap: 11px;
    background: var(--ink-900); color: #fff;
    padding: 12px 16px; border-radius: var(--r-sm);
    box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500;
    min-width: 260px; max-width: 380px;
    animation: toast-in .28s var(--ease);
}
.toast.is-out { animation: toast-out .2s var(--ease) forwards; }
.toast__dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; }
.toast--success .toast__dot { background: var(--brand-400); }
.toast--danger .toast__dot { background: var(--danger); }
.toast--info .toast__dot { background: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ----- 15. Modal ------------------------------------------------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 150;
    background: rgba(11, 21, 18, .5);
    backdrop-filter: blur(2px);
    display: grid; place-items: center;
    padding: 20px;
    animation: fade .15s var(--ease);
}
.modal {
    background: var(--surface); border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto;
    animation: modal-in .2s var(--ease);
}
.modal__head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal__title { font-size: 15.5px; font-weight: 650; }
.modal__close { margin-left: auto; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--text-mute); }
.modal__close:hover { background: var(--slate-100); color: var(--text); }
.modal__body { padding: 20px; }
.modal__foot { padding: 15px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
@keyframes fade { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.97); } }

/* ----- 16. Empty / loading states -------------------------------- */
.empty { text-align: center; padding: 46px 24px; }
.empty__art { width: 60px; height: 60px; border-radius: var(--r-lg); background: var(--brand-50); color: var(--brand-500); display: grid; place-items: center; margin: 0 auto 16px; }
.empty__art svg { width: 28px; height: 28px; }
.empty__title { font-size: 15px; font-weight: 640; }
.empty__text { color: var(--text-soft); font-size: 13px; margin: 5px auto 18px; max-width: 340px; }

.skeleton { background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 37%, var(--slate-100) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.spinner { width: 20px; height: 20px; border: 2.5px solid var(--slate-200); border-top-color: var(--brand-500); border-radius: 999px; animation: spin .7s linear infinite; }

/* ----- 17. Utilities ------------------------------------------------- */
.stack { display: flex; flex-direction: column; }
.stack-2 { gap: 8px; } .stack-3 { gap: 12px; } .stack-4 { gap: 16px; } .stack-6 { gap: 24px; }
.row { display: flex; align-items: center; }
.row-2 { gap: 8px; } .row-3 { gap: 12px; } .row-4 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.center { align-items: center; }
.grid { display: grid; }
.hide { display: none; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-soft { color: var(--text-soft); }
.text-mute { color: var(--text-mute); }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.dl-grid { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; font-size: 13px; }
.dl-grid dt { color: var(--text-mute); }
.dl-grid dd { color: var(--text); }

.section-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
/* Permite que las columnas se encojan y el texto trunque (evita scroll horizontal). */
.section-grid > * { min-width: 0; }
@media (max-width: 940px) { .section-grid { grid-template-columns: 1fr; } }

/* ----- 18. Mobile nav --------------------------------------------- */
.nav__backdrop { display: none; }
@media (max-width: 1024px) {
    .app, .app.is-collapsed { grid-template-columns: 1fr; }
    .nav {
        position: fixed; left: 0; top: 0; bottom: 0;
        width: var(--nav-w);
        transform: translateX(-100%);
        transition: transform .24s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .app.is-mobile-open .nav { transform: none; }
    .app.is-mobile-open .nav__backdrop {
        display: block; position: fixed; inset: 0; z-index: 39;
        background: rgba(11, 21, 18, .45); animation: fade .15s var(--ease);
    }

    /* En móvil el menú siempre se ve completo (no hay modo contraído) */
    .nav__collapse { display: none; }
    .is-collapsed .nav__link > span,
    .is-collapsed .nav__title,
    .is-collapsed .nav__brand-link,
    .is-collapsed .nav__section span,
    .is-collapsed .nav__vendor span:last-child { display: revert; }
    .is-collapsed .nav__link { justify-content: flex-start; padding: 9px 11px; }
    .is-collapsed .nav__brand { justify-content: flex-start; padding: 16px 14px 14px 18px; }
    .is-collapsed .nav__section { height: auto; margin: 16px 0 0; padding: 0 10px 6px; background: none; }
    .is-collapsed .nav__badge { position: static; border: 0; min-width: 18px; height: 18px; font-size: 10.5px; }
    .is-collapsed .nav__vendor { justify-content: flex-start; padding: 10px 11px; }

    /* Barra superior en verde (marca) — en móvil/tablet es la única nav visible */
    .topbar {
        background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
        backdrop-filter: none;
        border-bottom-color: rgba(255, 255, 255, .16);
    }
    .topbar__toggle, .topbar__icon-btn { color: rgba(255, 255, 255, .92); }
    .topbar__toggle:hover, .topbar__icon-btn:hover,
    .topbar__right [data-dropdown]:hover { background: rgba(255, 255, 255, .16); color: #fff; }
    .topbar__search { display: none; }
    .topbar .avatar { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .45); }
    .topbar__right [data-dropdown] svg { color: rgba(255, 255, 255, .8); }
    .notif__dot { border-color: var(--brand-600); }
}
@media (max-width: 560px) {
    .content { padding: 20px 15px 48px; }
    .topbar__search { display: none; }
    .stat__value { font-size: 22px; }

    /* El panel de notificaciones ocupa el ancho de la pantalla (no se sale por la izquierda) */
    .notif__menu {
        position: fixed;
        top: calc(var(--topbar-h) + 6px);
        left: 8px; right: 8px;
        width: auto;
    }
    /* Cualquier otro menú desplegable: que no se desborde */
    .dropdown__menu { max-width: calc(100vw - 16px); }
}
