/* =============================================================================
   ZonaBoxeo — Design system desde 0.
   CSS puro · monocromo blanco y negro · Inter · sin Tailwind.
   ============================================================================= */

/* ---------- Reset moderno ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 4; }
body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}
img, svg, video, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
[hidden], .hidden { display: none !important; }

/* ---------- Tema ---------- */
:root {
    --bg: #ffffff;
    --bg-2: #fafafa;
    --bg-3: #f5f5f5;
    --bg-card: #ffffff;
    --bg-hover: #f5f5f5;
    --bg-muted: #f7f7f7;

    --border: #ececec;
    --border-2: #d4d4d4;
    --border-strong: #a3a3a3;

    --text: #0a0a0a;
    --text-2: #404040;
    --text-3: #737373;
    --text-4: #a3a3a3;
    --text-disabled: #d4d4d4;

    --acc: #0a0a0a;
    --acc-hover: #1f1f1f;
    --ring: rgb(10 10 10 / 0.10);

    --ok: #16a34a;  --ok-bg: #f0fdf4;  --ok-fg: #166534;
    --warn: #d97706; --warn-bg: #fffbeb; --warn-fg: #92400e;
    --err: #dc2626;  --err-bg: #fef2f2;  --err-fg: #991b1b;
    --info: #2563eb; --info-bg: #eff6ff; --info-fg: #1e40af;

    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.04);
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.05), 0 1px 2px rgb(0 0 0 / 0.04);
    --shadow-md: 0 4px 12px -3px rgb(0 0 0 / 0.07), 0 2px 4px rgb(0 0 0 / 0.04);
    --shadow-lg: 0 16px 32px -8px rgb(0 0 0 / 0.10), 0 6px 12px -4px rgb(0 0 0 / 0.06);
    --shadow-xl: 0 28px 56px -12px rgb(0 0 0 / 0.18), 0 12px 24px -6px rgb(0 0 0 / 0.10);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --duration: 180ms;

    --sidebar-w: 252px;
    --topbar-h: 56px;
    --content-max: 1400px;
}
:root.dark {
    --bg: #0a0a0a;
    --bg-2: #131313;
    --bg-3: #1a1a1a;
    --bg-card: #131313;
    --bg-hover: #1f1f1f;
    --bg-muted: #1a1a1a;
    --border: #232323;
    --border-2: #303030;
    --border-strong: #535353;
    --text: #fafafa;
    --text-2: #d4d4d4;
    --text-3: #a3a3a3;
    --text-4: #737373;
    --text-disabled: #404040;
    --acc: #fafafa;
    --acc-hover: #ededed;
    --ring: rgb(255 255 255 / 0.12);
    --shadow-md: 0 4px 12px -3px rgb(0 0 0 / 0.5), 0 2px 4px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 16px 32px -8px rgb(0 0 0 / 0.55), 0 6px 12px -4px rgb(0 0 0 / 0.35);
    --shadow-xl: 0 28px 56px -12px rgb(0 0 0 / 0.65);
}

::selection { background: var(--text); color: var(--bg); }

/* ---------- Tipografía ---------- */
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }
.tabular { font-variant-numeric: tabular-nums; }
h1, h2, h3, h4, h5 { letter-spacing: -0.015em; line-height: 1.2; color: var(--text); font-weight: 600; }
.title-xl { font-size: 2rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; }
.title-lg { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.title-md { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
.title-sm { font-size: 0.9375rem; font-weight: 600; }
.muted { color: var(--text-3); }
.muted-2 { color: var(--text-2); }
.subtle { color: var(--text-4); }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.8125rem; }
.text-md { font-size: 0.9375rem; }
.weight-500 { font-weight: 500; }
.weight-600 { font-weight: 600; }

/* ---------- Layout: shell ---------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}
.app-main { min-width: 0; display: flex; flex-direction: column; }
.app-content {
    flex: 1;
    padding: 2rem 2rem 4rem;
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    animation: fadeIn 240ms var(--ease);
}
@media (max-width: 1024px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-content { padding: 1.25rem 1rem 3rem; }
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: sticky; top: 0;
    height: 100vh;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow: hidden;
}
@media (max-width: 1024px) {
    .sidebar {
        position: fixed; inset: 0 auto 0 0;
        z-index: 60;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 280ms var(--ease);
        height: 100vh;
    }
    .sidebar.open { transform: translateX(0); }
}
.sidebar-overlay {
    position: fixed; inset: 0; z-index: 55;
    background: rgb(10 10 10 / 0.4);
    backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none;
    transition: opacity 200ms;
    display: none;
}
@media (max-width: 1024px) { .sidebar-overlay { display: block; } }
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

.sidebar-brand {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 1rem 1.125rem;
    border-bottom: 1px solid var(--border);
    height: var(--topbar-h);
    flex-shrink: 0;
}
.brand-mark {
    width: 1.875rem; height: 1.875rem;
    background: var(--text); color: var(--bg);
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em;
}
.brand-name { font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.01em; flex: 1; }
.sidebar-search { padding: 0.875rem 0.75rem 0.5rem; flex-shrink: 0; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.5rem 0 1rem; }
.nav-section {
    padding: 0.875rem 1.125rem 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-4);
}
.nav-item {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    margin: 0.0625rem 0.5rem;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 0.875rem; font-weight: 500;
    transition: background var(--duration), color var(--duration);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--text); color: var(--bg); font-weight: 600; }
.nav-item .icon { width: 1rem; height: 1rem; flex-shrink: 0; opacity: 0.85; }
.nav-item.active .icon { opacity: 1; }
.nav-item .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-badge {
    font-size: 0.6875rem; font-weight: 600;
    padding: 0.0625rem 0.4375rem;
    border-radius: 999px;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-3);
    line-height: 1.4;
    min-width: 1.25rem;
    text-align: center;
}
.nav-item.active .nav-badge { background: var(--bg); color: var(--text); border-color: transparent; }

.sidebar-user { border-top: 1px solid var(--border); padding: 0.625rem; flex-shrink: 0; }
.user-chip {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: 10px;
    transition: background var(--duration);
}
.user-chip:hover { background: var(--bg-hover); }
.avatar {
    width: 2rem; height: 2rem;
    background: var(--text); color: var(--bg);
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.02em;
}
.user-meta { flex: 1; min-width: 0; line-height: 1.2; }
.user-name { font-size: 0.8125rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.6875rem; color: var(--text-3); text-transform: capitalize; margin-top: 0.0625rem; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    padding: 0 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem;
    background: rgb(255 255 255 / 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
:root.dark .topbar { background: rgb(10 10 10 / 0.85); }
.crumb { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--text-3); }
.crumb a { transition: color var(--duration); }
.crumb a:hover { color: var(--text); }
.crumb-sep { color: var(--text-4); }
.crumb-current { color: var(--text); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 0.375rem; }
.icon-btn {
    width: 2.25rem; height: 2.25rem;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px;
    color: var(--text-2);
    transition: background var(--duration), color var(--duration);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.menu-toggle { display: none; }
@media (max-width: 1024px) { .menu-toggle { display: inline-flex; } }

/* ---------- Page header ---------- */
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}
.page-head-text { flex: 1; min-width: 0; }
.page-head h1 { font-size: 1.875rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; }
.page-head p { font-size: 0.9375rem; color: var(--text-3); margin-top: 0.4375rem; max-width: 60ch; }
.page-head-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* Section heading */
.section-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin: 2rem 0 1rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}
.section-head h2 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
.section-head .count { font-size: 0.8125rem; color: var(--text-4); font-weight: 500; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.4375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem; font-weight: 500;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    transition: background var(--duration), border-color var(--duration), color var(--duration), transform 80ms;
    white-space: nowrap;
    line-height: 1.25;
    user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn .icon { width: 1rem; height: 1rem; flex-shrink: 0; }
.btn-sm { padding: 0.375rem 0.625rem; font-size: 0.8125rem; border-radius: 7px; gap: 0.375rem; }
.btn-sm .icon { width: 0.875rem; height: 0.875rem; }
.btn-sm.btn-icon { padding: 0.375rem; width: 1.875rem; height: 1.875rem; }
.btn-icon { padding: 0.5rem; width: 2.25rem; height: 2.25rem; }
.btn-lg { padding: 0.625rem 1.0625rem; font-size: 0.9375rem; border-radius: 10px; }

.btn-primary {
    background: var(--text); color: var(--bg); border-color: var(--text);
}
.btn-primary:hover:not(:disabled) { background: var(--acc-hover); border-color: var(--acc-hover); }
:root.dark .btn-primary { color: #0a0a0a; }
:root.dark .btn-primary:hover:not(:disabled) { color: #0a0a0a; }

.btn-secondary {
    background: var(--bg); color: var(--text); border-color: var(--border-2);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }

.btn-danger {
    background: var(--err); color: #fff; border-color: var(--err);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }

.btn-danger-ghost { color: var(--err); border-color: transparent; }
.btn-danger-ghost:hover:not(:disabled) { background: var(--err-bg); border-color: transparent; color: var(--err); }

/* ---------- Inputs ---------- */
.input, .textarea, .select {
    display: block; width: 100%;
    padding: 0.5625rem 0.875rem;
    font-size: 0.875rem; line-height: 1.5;
    color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--border-2);
    border-radius: 9px;
    transition: border-color var(--duration), box-shadow var(--duration);
    appearance: none;
    -webkit-appearance: none;
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--text);
    box-shadow: 0 0 0 3px var(--ring);
}
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
.input-sm { padding: 0.375rem 0.625rem; font-size: 0.8125rem; border-radius: 7px; }
.select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}
.label {
    display: block;
    font-size: 0.8125rem; font-weight: 500;
    color: var(--text-2);
    margin-bottom: 0.4375rem;
}
.label .req { color: var(--err); margin-left: 0.125rem; }
.field-error { color: var(--err); font-size: 0.75rem; margin-top: 0.3125rem; }
.field-help { color: var(--text-3); font-size: 0.75rem; margin-top: 0.3125rem; }

.input-with-icon { position: relative; }
.input-with-icon .input { padding-left: 2.25rem; }
.input-with-icon .icon-pre {
    position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
    color: var(--text-4); width: 1rem; height: 1rem; pointer-events: none;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 640px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }
.form-group { margin-bottom: 1rem; }

.input-group {
    display: flex;
    border: 1px solid var(--border-2);
    border-radius: 9px;
    overflow: hidden;
    background: var(--bg-card);
}
.input-group:focus-within { border-color: var(--text); box-shadow: 0 0 0 3px var(--ring); }
.input-group .input { border: 0; box-shadow: none !important; border-radius: 0; }
.input-group .input:focus { box-shadow: none; }
.input-group .input + .input { border-left: 1px solid var(--border); }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--duration), box-shadow var(--duration);
}
.card-padded { padding: 1.375rem; }
.card-head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.card-head h3 { font-size: 0.9375rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-foot {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg-2);
}

/* ---------- Métricas (strip) ---------- */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
    margin-bottom: 1.75rem;
}
.metric { padding: 1.125rem 1.375rem; border-right: 1px solid var(--border); }
.metric:last-child { border-right: 0; }
@media (max-width: 640px) {
    .metric { border-right: 0; border-bottom: 1px solid var(--border); }
    .metric:last-child { border-bottom: 0; }
}
.metric-label { font-size: 0.8125rem; font-weight: 500; color: var(--text-3); margin-bottom: 0.4375rem; }
.metric-value { font-size: 1.625rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric-hint { font-size: 0.75rem; color: var(--text-4); margin-top: 0.3125rem; }
.metric-hint a { color: var(--text-3); text-decoration: underline; text-decoration-color: var(--border-2); text-underline-offset: 2px; transition: color 120ms; }
.metric-hint a:hover { color: var(--text); text-decoration-color: var(--text); }

/* ---------- Tablas ---------- */
.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem; font-weight: 500;
    color: var(--text-3);
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    vertical-align: middle;
}
.table tbody tr { transition: background 100ms; }
.table tbody tr:hover { background: var(--bg-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.t-right { text-align: right; }
.t-center { text-align: center; }
.t-nowrap { white-space: nowrap; }

/* ---------- Badge / Pill / Chip ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    font-size: 0.75rem; font-weight: 500;
    border-radius: 6px;
    background: var(--bg-3);
    color: var(--text-2);
    line-height: 1.4;
}
.badge-success { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn    { background: var(--warn-bg); color: var(--warn-fg); }
.badge-danger  { background: var(--err-bg); color: var(--err-fg); }
.badge-info    { background: var(--info-bg); color: var(--info-fg); }
.badge-mono    { background: var(--text); color: var(--bg); }
.badge-outline { background: transparent; border: 1px solid var(--border-2); }
:root.dark .badge-success { background: rgb(22 101 52 / 0.25); color: #86efac; }
:root.dark .badge-warn    { background: rgb(146 64 14 / 0.25); color: #fcd34d; }
:root.dark .badge-danger  { background: rgb(153 27 27 / 0.25); color: #fca5a5; }
:root.dark .badge-info    { background: rgb(30 64 175 / 0.25); color: #93c5fd; }

/* Tokens semánticos en DARK: fondo translúcido oscuro + texto claro legible
   (en claro son fondo claro + texto oscuro). Esto arregla el texto ilegible sobre
   verde/ámbar/rojo/azul en dark para alerts, pills, trends, timeline, etc. */
:root.dark {
    --ok-bg:   rgb(22 101 52 / 0.22);  --ok-fg:   #86efac;
    --warn-bg: rgb(146 64 14 / 0.22);  --warn-fg: #fcd34d;
    --err-bg:  rgb(153 27 27 / 0.22);  --err-fg:  #fca5a5;
    --info-bg: rgb(30 64 175 / 0.22);  --info-fg: #93c5fd;
}
:root.dark .alert-success { border-color: rgb(34 197 94 / 0.35); }
:root.dark .alert-danger  { border-color: rgb(248 113 113 / 0.35); }
:root.dark .alert-warn    { border-color: rgb(245 158 11 / 0.35); }
:root.dark .alert-info    { border-color: rgb(96 165 250 / 0.35); }

.pill {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.1875rem 0.5rem 0.1875rem 0.4375rem;
    font-size: 0.75rem; font-weight: 500;
    border-radius: 999px;
    background: var(--bg-3);
    color: var(--text-2);
    line-height: 1.4;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.pill-ok   { background: var(--ok-bg);   color: var(--ok-fg); }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill-err  { background: var(--err-bg);  color: var(--err-fg); }

.chip {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    font-size: 0.75rem; font-weight: 500;
    border-radius: 6px;
    background: var(--bg-3);
    color: var(--text-2);
}
.chip-mono { font-family: 'JetBrains Mono', monospace; font-size: 0.6875rem; }

/* ---------- Alert ---------- */
.alert {
    display: flex; align-items: flex-start; gap: 0.625rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--text);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
.alert .icon { width: 1rem; height: 1rem; flex-shrink: 0; margin-top: 0.125rem; }
.alert-success { border-color: #bbf7d0; background: var(--ok-bg);   color: var(--ok-fg); }
.alert-danger  { border-color: #fecaca; background: var(--err-bg);  color: var(--err-fg); }
.alert-warn    { border-color: #fde68a; background: var(--warn-bg); color: var(--warn-fg); }
.alert-info    { border-color: #bfdbfe; background: var(--info-bg); color: var(--info-fg); }

/* ---------- Modal ---------- */
.modal {
    position: fixed; inset: 0; z-index: 100;
    background: rgb(10 10 10 / 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: flex-start; justify-content: center;
    padding: 4rem 1rem 2rem;
    overflow-y: auto;
}
.modal.open { display: flex; }
.modal-box {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%; max-width: 540px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    margin: auto 0;
    animation: modalIn 220ms var(--ease);
    display: flex; flex-direction: column;
}
.modal-box-lg { max-width: 760px; }
.modal-box-xl { max-width: 980px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head {
    padding: 1.125rem 1.375rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.modal-head h3 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
.modal-body { padding: 1.375rem; overflow-y: auto; }
.modal-foot {
    padding: 1rem 1.375rem;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 0.5rem;
    background: var(--bg-2);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 3.5rem 1.5rem; }
.empty-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 3.5rem; height: 3.5rem;
    background: var(--bg-3);
    border-radius: var(--radius-lg);
    color: var(--text-3);
    margin-bottom: 1rem;
}
.empty-title { font-size: 1.0625rem; font-weight: 600; margin-bottom: 0.4375rem; }
.empty-desc { color: var(--text-3); max-width: 42ch; margin: 0 auto 1.25rem; line-height: 1.55; }

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex; align-items: center; gap: 0.625rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.toolbar-search { flex: 1; min-width: 220px; max-width: 360px; }
.toolbar .select { width: auto; min-width: 180px; }

/* ---------- Categoría cards ---------- */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.875rem;
}
.cat-card {
    position: relative;
    display: flex; flex-direction: column; gap: 0.625rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--duration), box-shadow var(--duration), transform var(--duration);
    cursor: pointer;
    min-height: 160px;
}
.cat-card:hover, .cat-card:focus-within {
    border-color: var(--text);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.cat-card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.cat-card-mark {
    width: 2.25rem; height: 2.25rem;
    background: var(--text); color: var(--bg);
    border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em;
}
.cat-card-actions { display: flex; gap: 0.125rem; opacity: 0; transition: opacity var(--duration); }
.cat-card:hover .cat-card-actions, .cat-card:focus-within .cat-card-actions { opacity: 1; }
.cat-card-name { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
.cat-card-desc {
    font-size: 0.875rem; color: var(--text-3); line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cat-card-foot {
    margin-top: auto; padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.cat-card-count { font-size: 0.8125rem; color: var(--text-3); transition: color var(--duration); }
.cat-card-count strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-card-count:hover { color: var(--text); }

/* ---------- Producto cards ---------- */
.prod-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.875rem;
}
.prod-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--duration), box-shadow var(--duration), transform var(--duration);
    cursor: pointer;
    display: flex; flex-direction: column;
    position: relative;
}
.prod-card:hover { border-color: var(--text); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.prod-card-img {
    aspect-ratio: 1; background: var(--bg-3);
    overflow: hidden; position: relative;
}
.prod-card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 480ms var(--ease); }
.prod-card:hover .prod-card-img img { transform: scale(1.05); }
.prod-card-status { position: absolute; top: 0.625rem; right: 0.625rem; }
.prod-card-multi {
    position: absolute; bottom: 0.625rem; left: 0.625rem;
    background: rgb(10 10 10 / 0.75); color: #fff;
    padding: 0.1875rem 0.4375rem;
    font-size: 0.6875rem; font-weight: 500;
    border-radius: 999px;
    backdrop-filter: blur(4px);
    display: inline-flex; align-items: center; gap: 0.25rem;
}
.prod-card-body { padding: 0.875rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.4375rem; flex: 1; }
.prod-sku {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    color: var(--text-3);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.prod-name {
    font-size: 0.9375rem; font-weight: 500;
    line-height: 1.4;
    color: var(--text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    min-height: 2.5em;
}
.prod-meta {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-top: auto; padding-top: 0.5rem;
}
.prod-price { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.prod-stock { font-size: 0.75rem; color: var(--text-3); font-variant-numeric: tabular-nums; text-align: right; }
.prod-card-actions {
    display: flex; gap: 0.25rem;
    padding: 0.5rem 0.75rem 0.75rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}
.prod-card-actions .btn { flex: 1; }

/* ---------- Inventario / stock ---------- */
.inv-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1rem;
    transition: border-color var(--duration), box-shadow var(--duration);
}
.inv-card:hover { border-color: var(--border-2); }
.inv-head {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.inv-thumb {
    width: 3.25rem; height: 3.25rem;
    background: var(--bg-3);
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
}
.inv-thumb img { width: 100%; height: 100%; object-fit: cover; }
.inv-head-text { flex: 1; min-width: 0; }
.inv-head-name { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.inv-head-meta { font-size: 0.75rem; color: var(--text-3); margin-top: 0.1875rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.inv-head-meta .mono { font-family: 'JetBrains Mono', monospace; }
.inv-head-stats { display: flex; gap: 1.5rem; align-items: center; }
.inv-stat { text-align: right; }
.inv-stat-label { font-size: 0.6875rem; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.inv-stat-value { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.inv-stat-value.low { color: var(--err); }
.inv-stat-value.med { color: var(--warn); }

.inv-variants {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0;
    border-top: 0;
}
.inv-variant {
    padding: 0.875rem 1rem;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    display: flex; flex-direction: column; gap: 0.5rem;
    transition: background var(--duration);
}
.inv-variant:hover { background: var(--bg-2); }
.inv-variant-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.inv-variant-tags { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.inv-variant-stock {
    display: flex; align-items: center; gap: 0.5rem;
}
.inv-variant-stock .input {
    width: 4.5rem; padding: 0.3125rem 0.5rem;
    font-size: 0.8125rem; font-variant-numeric: tabular-nums;
    text-align: center;
}
.inv-variant-min {
    font-size: 0.6875rem; color: var(--text-4);
    display: flex; align-items: center; gap: 0.25rem;
}
.inv-variant-min input {
    width: 3rem; padding: 0.125rem 0.3125rem;
    font-size: 0.6875rem; text-align: center;
    background: transparent; border: 1px solid var(--border);
    border-radius: 5px; color: var(--text-2);
    font-variant-numeric: tabular-nums;
}
.inv-variant-min input:focus { outline: none; border-color: var(--text); background: var(--bg-card); }

.inv-add-variant {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.inv-add-variant .label { margin: 0; }

/* Stock indicator dot inline */
.stock-dot {
    display: inline-block;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--ok);
    margin-right: 0.4375rem;
}
.stock-dot.low { background: var(--err); }
.stock-dot.med { background: var(--warn); }
.stock-dot.zero { background: var(--text-4); }

/* Stock bar */
.stock-bar {
    height: 4px; background: var(--bg-3); border-radius: 999px; overflow: hidden;
    margin-top: 0.375rem;
}
.stock-bar > i {
    display: block; height: 100%; background: var(--text);
    border-radius: 999px; transition: width 400ms var(--ease);
}
.stock-bar.low > i { background: var(--err); }
.stock-bar.med > i { background: var(--warn); }
.stock-bar.high > i { background: var(--ok); }

/* ---------- Toast ---------- */
.toast-stack {
    position: fixed; bottom: 1rem; right: 1rem;
    z-index: 200;
    display: flex; flex-direction: column; gap: 0.5rem;
    width: min(360px, calc(100vw - 2rem));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex; align-items: flex-start; gap: 0.625rem;
    padding: 0.75rem 0.875rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    color: var(--text);
    animation: toastIn 220ms var(--ease);
}
.toast .icon { width: 1rem; height: 1rem; flex-shrink: 0; margin-top: 0.125rem; }
.toast .toast-msg { flex: 1; line-height: 1.45; }
.toast .toast-close {
    color: var(--text-4);
    transition: color 120ms;
    padding: 0 0.125rem;
    margin: -0.125rem -0.125rem -0.125rem 0;
}
.toast .toast-close:hover { color: var(--text); }
.toast-success { border-left: 3px solid var(--ok); }
.toast-success .icon { color: var(--ok); }
.toast-error   { border-left: 3px solid var(--err); }
.toast-error .icon { color: var(--err); }
.toast-warning { border-left: 3px solid var(--warn); }
.toast-warning .icon { color: var(--warn); }
.toast-info .icon { color: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- Drag&drop / file ---------- */
.dropzone {
    border: 1.5px dashed var(--border-2);
    background: var(--bg-2);
    border-radius: var(--radius-lg);
    padding: 1.75rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--duration), background var(--duration);
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--text);
    background: var(--bg-2);
}
.dropzone .dropzone-icon { color: var(--text-3); margin: 0 auto 0.5rem; }
.dropzone p { font-size: 0.875rem; color: var(--text-3); }
.dropzone strong { color: var(--text); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }

/* Image manager */
.img-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.625rem;
    margin-top: 0.875rem;
}
.img-list-item {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: grab;
}
.img-list-item:active { cursor: grabbing; }
.img-list-item img { width: 100%; height: 100%; object-fit: cover; }
.img-list-item .img-overlay {
    position: absolute; inset: 0;
    background: linear-gradient(to top, rgb(0 0 0 / 0.7), transparent 50%);
    opacity: 0; transition: opacity var(--duration);
    display: flex; align-items: flex-end; justify-content: space-between;
    padding: 0.5rem;
}
.img-list-item:hover .img-overlay { opacity: 1; }
.img-list-item .img-btn {
    width: 1.875rem; height: 1.875rem;
    border-radius: 7px;
    background: rgb(255 255 255 / 0.95);
    color: #0a0a0a;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 120ms;
}
.img-list-item .img-btn:hover { background: #fff; }
.img-list-item .img-btn.danger { background: var(--err); color: #fff; }
.img-list-item .img-btn.danger:hover { background: #b91c1c; }
.img-list-item.is-principal {
    border: 2px solid var(--text);
}
.img-list-item .star-mark {
    position: absolute; top: 0.4375rem; left: 0.4375rem;
    background: var(--text); color: var(--bg);
    padding: 0.125rem 0.4375rem;
    border-radius: 999px;
    font-size: 0.625rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: 0.25rem;
}

/* ---------- Confirm dialog ---------- */
.confirm-box { max-width: 440px; }
.confirm-icon-wrap {
    width: 2.5rem; height: 2.5rem;
    border-radius: 999px;
    background: var(--err-bg); color: var(--err);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ---------- Utilities ---------- */
.flex { display: flex; }
.iflex { display: inline-flex; }
.grid { display: grid; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-start { align-items: flex-start; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.flex-1 { flex: 1 1 0%; min-width: 0; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.relative { position: relative; }

.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

/* ---------- Scrollbar ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ---------- Focus visible ---------- */
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
    border-radius: 6px;
}
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
    outline: none;
}

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 280ms var(--ease) both; }

body.modal-open { overflow: hidden; }

/* =============================================================================
   Dashboard — componentes especiales
   ============================================================================= */

/* Hero KPI grande */
.kpi-hero {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}
@media (max-width: 900px) { .kpi-hero { grid-template-columns: 1fr; } }
.kpi-hero-main {
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-xl);
    padding: 1.75rem 2rem;
    position: relative;
    overflow: hidden;
}
.kpi-hero-main::before {
    content: ''; position: absolute; right: -2rem; top: -2rem;
    width: 16rem; height: 16rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgb(255 255 255 / 0.06) 0%, transparent 60%);
}
:root.dark .kpi-hero-main { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.kpi-hero-eyebrow {
    font-size: 0.75rem; font-weight: 500;
    color: var(--bg-card-2);
    opacity: 0.65; letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}
:root.dark .kpi-hero-eyebrow { color: var(--text-3); opacity: 1; }
.kpi-hero-value {
    font-size: clamp(2rem, 5vw, 3rem); font-weight: 600;
    letter-spacing: -0.03em; line-height: 1.05;
    font-variant-numeric: tabular-nums;
}
.kpi-hero-sub { margin-top: 0.4375rem; font-size: 0.875rem; opacity: 0.75; }
.kpi-hero-sub strong { font-weight: 600; }
.kpi-hero-foot {
    position: relative;
    margin-top: 1.375rem;
    padding-top: 1rem;
    border-top: 1px solid rgb(255 255 255 / 0.1);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
:root.dark .kpi-hero-foot { border-color: var(--border); }
.kpi-hero-foot-item { font-size: 0.75rem; opacity: 0.85; }
.kpi-hero-foot-item strong { display: block; font-size: 1rem; font-weight: 600; opacity: 1; margin-top: 0.125rem; font-variant-numeric: tabular-nums; }

/* Trend pill (variación) */
.trend {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    font-size: 0.75rem; font-weight: 600;
    border-radius: 999px;
    background: var(--bg-3);
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}
.trend.up   { background: var(--ok-bg); color: var(--ok-fg); }
.trend.down { background: var(--err-bg); color: var(--err-fg); }

/* Mini grid de 4 KPIs */
.mini-kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}
.mini-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.125rem;
    transition: border-color var(--duration);
}
.mini-kpi:hover { border-color: var(--border-2); }
.mini-kpi-label { font-size: 0.75rem; color: var(--text-3); font-weight: 500; }
.mini-kpi-value { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 0.375rem; }
.mini-kpi-foot { font-size: 0.75rem; color: var(--text-4); margin-top: 0.3125rem; display: flex; align-items: center; gap: 0.375rem; }

/* Spark bars (gráfica simple CSS) */
.spark-bars {
    display: flex; align-items: flex-end; gap: 0.25rem;
    height: 160px;
    padding: 0.5rem 0;
}
.spark-bar {
    flex: 1;
    background: var(--bg-3);
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: background var(--duration);
    cursor: pointer;
    min-height: 2px;
}
.spark-bar:hover { background: var(--text); }
.spark-bar.is-today { background: var(--text); }
.spark-bar:hover::after, .spark-bar.is-today::after {
    content: attr(data-value);
    position: absolute;
    bottom: calc(100% + 0.375rem);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 0.25rem 0.4375rem;
    border-radius: 5px;
    font-size: 0.6875rem;
    white-space: nowrap;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    z-index: 5;
}
.spark-axis {
    display: flex; justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.6875rem; color: var(--text-4);
    font-family: 'JetBrains Mono', monospace;
}

/* Donut / distribución (CSS conic-gradient) */
.donut {
    width: 140px; height: 140px;
    border-radius: 50%;
    display: grid; place-items: center;
    position: relative;
    flex-shrink: 0;
}
.donut::before {
    content: '';
    position: absolute; inset: 18px;
    background: var(--bg-card);
    border-radius: 50%;
}
.donut-center {
    position: relative; z-index: 2;
    text-align: center;
}
.donut-center strong { display: block; font-size: 1.375rem; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.donut-center span { display: block; font-size: 0.75rem; color: var(--text-3); margin-top: 0.125rem; }

.donut-legend { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; min-width: 0; }
.donut-legend-row { display: flex; align-items: center; gap: 0.625rem; font-size: 0.875rem; }
.donut-legend-color { width: 0.625rem; height: 0.625rem; border-radius: 3px; flex-shrink: 0; }
.donut-legend-label { flex: 1; min-width: 0; color: var(--text-2); }
.donut-legend-value { font-variant-numeric: tabular-nums; font-weight: 500; }

/* Ranking list (top productos) */
.rank-list { display: flex; flex-direction: column; gap: 0.5rem; }
.rank-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    transition: background 100ms;
    text-decoration: none;
    color: var(--text);
}
.rank-item:hover { background: var(--bg-2); }
.rank-pos {
    width: 1.5rem; height: 1.5rem;
    flex-shrink: 0;
    background: var(--bg-3);
    color: var(--text-3);
    border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.rank-item:first-child .rank-pos { background: var(--text); color: var(--bg); }
.rank-item-img {
    width: 2rem; height: 2rem; flex-shrink: 0;
    background: var(--bg-3); border-radius: 6px;
    object-fit: cover;
}
.rank-item-text { flex: 1; min-width: 0; }
.rank-item-name { font-size: 0.875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-item-meta { font-size: 0.75rem; color: var(--text-3); margin-top: 0.0625rem; }
.rank-item-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    flex-shrink: 0;
}
.rank-item-value-meta { font-size: 0.6875rem; color: var(--text-4); font-weight: 400; margin-top: 0.0625rem; }

/* Alert horizontal con CTA */
.callout {
    display: flex; align-items: center; gap: 0.875rem;
    padding: 0.875rem 1.125rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}
.callout-icon {
    width: 2.25rem; height: 2.25rem;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--bg-3);
    color: var(--text-2);
    display: inline-flex; align-items: center; justify-content: center;
}
.callout.warn .callout-icon { background: var(--warn-bg); color: var(--warn-fg); }
.callout.danger .callout-icon { background: var(--err-bg); color: var(--err-fg); }
.callout-text { flex: 1; min-width: 0; }
.callout-title { font-size: 0.9375rem; font-weight: 600; }
.callout-desc { font-size: 0.8125rem; color: var(--text-3); margin-top: 0.0625rem; }

/* Compact list items (ventas/envíos/encargos) */
.list-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1.125rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: background 100ms;
}
.list-item:hover { background: var(--bg-2); }
.list-item:last-child { border-bottom: 0; }
.list-item-icon {
    width: 2.125rem; height: 2.125rem;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--bg-3);
    color: var(--text-2);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.6875rem; font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-size: 0.875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-meta { font-size: 0.75rem; color: var(--text-3); margin-top: 0.125rem; display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.list-item-aside { text-align: right; flex-shrink: 0; }
.list-item-aside-main { font-weight: 500; font-variant-numeric: tabular-nums; font-size: 0.875rem; }
.list-item-aside-sub { font-size: 0.6875rem; color: var(--text-4); margin-top: 0.125rem; }

/* =============================================================================
   Chat IA — panel lateral
   ============================================================================= */

.chat-panel {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(460px, 100vw);
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 80;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 320ms var(--ease);
}
.chat-panel.open { transform: translateX(0); }

.chat-overlay {
    position: fixed; inset: 0; z-index: 75;
    background: rgb(10 10 10 / 0.4);
    backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none;
    transition: opacity 250ms;
}
.chat-overlay.show { opacity: 1; pointer-events: auto; }

.chat-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    height: var(--topbar-h);
    flex-shrink: 0;
    background: var(--bg-card);
}
.chat-head-title {
    display: flex; align-items: center; gap: 0.5rem;
    min-width: 0;
}
.chat-head-mark {
    width: 1.75rem; height: 1.75rem;
    background: var(--text); color: var(--bg);
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.chat-head-name { font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.01em; }
.chat-head-actions { display: flex; gap: 0.125rem; }

.chat-conv-active {
    padding: 0.375rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-3);
    flex-shrink: 0;
}
.chat-conv-active strong { color: var(--text); font-weight: 500; }

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--bg-2);
}
.chat-history-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-3);
    font-size: 0.875rem;
}
.chat-history-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border-radius: 8px;
    transition: background 100ms;
    cursor: pointer;
}
.chat-history-item:hover { background: var(--bg-hover); }
.chat-history-item-text { flex: 1; min-width: 0; }
.chat-history-item-title {
    font-size: 0.875rem; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--text);
}
.chat-history-item-date { font-size: 0.6875rem; color: var(--text-4); margin-top: 0.0625rem; }
.chat-history-item-del {
    opacity: 0;
    transition: opacity 120ms;
    color: var(--err);
}
.chat-history-item:hover .chat-history-item-del { opacity: 1; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.125rem 1rem 0.5rem;
    display: flex; flex-direction: column;
    gap: 0.875rem;
}

.chat-msg {
    display: flex;
    gap: 0.625rem;
    max-width: 100%;
}
.chat-msg.user { justify-content: flex-end; }
.chat-msg-avatar {
    width: 1.75rem; height: 1.75rem;
    background: var(--bg-3);
    color: var(--text-2);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.chat-msg-bubble {
    padding: 0.5625rem 0.875rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.55;
    max-width: 85%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}
.chat-msg.user .chat-msg-bubble {
    background: var(--text);
    color: var(--bg);
    border-radius: 12px 12px 3px 12px;
}
:root.dark .chat-msg.user .chat-msg-bubble { color: #0a0a0a; }
.chat-msg.assistant .chat-msg-content {
    flex: 1;
    min-width: 0;
}
.chat-msg.assistant .chat-msg-bubble {
    background: transparent;
    color: var(--text);
    padding: 0.125rem 0;
    border-radius: 0;
}

/* Markdown rendering dentro del bubble del asistente */
.chat-msg-bubble.md {
    white-space: normal;
}
.chat-msg-bubble.md p {
    margin: 0 0 0.625rem;
    line-height: 1.6;
}
.chat-msg-bubble.md p:last-child { margin-bottom: 0; }
.chat-msg-bubble.md strong { font-weight: 600; color: var(--text); }
.chat-msg-bubble.md em { font-style: italic; }
.chat-msg-bubble.md del { text-decoration: line-through; color: var(--text-3); }
.chat-msg-bubble.md a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--border-2);
    text-underline-offset: 2px;
    transition: text-decoration-color 120ms;
}
.chat-msg-bubble.md a:hover { text-decoration-color: var(--text); }

.chat-msg-bubble.md h1,
.chat-msg-bubble.md h2,
.chat-msg-bubble.md h3,
.chat-msg-bubble.md h4 {
    font-weight: 600;
    letter-spacing: -0.015em;
    margin: 0.875rem 0 0.4375rem;
    color: var(--text);
    line-height: 1.3;
}
.chat-msg-bubble.md h1:first-child,
.chat-msg-bubble.md h2:first-child,
.chat-msg-bubble.md h3:first-child,
.chat-msg-bubble.md h4:first-child { margin-top: 0; }
.chat-msg-bubble.md h1 { font-size: 1.0625rem; }
.chat-msg-bubble.md h2 { font-size: 1rem; }
.chat-msg-bubble.md h3 { font-size: 0.9375rem; }
.chat-msg-bubble.md h4 { font-size: 0.875rem; color: var(--text-2); }

.chat-msg-bubble.md ul,
.chat-msg-bubble.md ol {
    margin: 0 0 0.625rem;
    padding-left: 1.25rem;
    list-style-position: outside;
}
.chat-msg-bubble.md ul { list-style: disc; }
.chat-msg-bubble.md ol { list-style: decimal; }
.chat-msg-bubble.md li {
    margin: 0.1875rem 0;
    line-height: 1.55;
}
.chat-msg-bubble.md li > ul,
.chat-msg-bubble.md li > ol {
    margin-top: 0.1875rem;
    margin-bottom: 0.1875rem;
}

.chat-msg-bubble.md code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125em;
    background: var(--bg-3);
    color: var(--text);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}
.chat-msg-bubble.md pre {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.625rem 0.75rem;
    margin: 0.5rem 0;
    overflow-x: auto;
    line-height: 1.5;
}
.chat-msg-bubble.md pre code {
    background: transparent;
    border: 0;
    padding: 0;
    font-size: 0.75rem;
    color: var(--text-2);
    border-radius: 0;
}

.chat-msg-bubble.md blockquote {
    margin: 0.5rem 0;
    padding: 0.4375rem 0.75rem;
    border-left: 3px solid var(--border-2);
    background: var(--bg-2);
    color: var(--text-2);
    border-radius: 0 6px 6px 0;
}
.chat-msg-bubble.md blockquote p:last-child { margin-bottom: 0; }

.chat-msg-bubble.md hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 0.875rem 0;
}

.chat-msg-bubble.md table {
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.8125rem;
    width: 100%;
}
.chat-msg-bubble.md th,
.chat-msg-bubble.md td {
    border: 1px solid var(--border);
    padding: 0.375rem 0.5rem;
    text-align: left;
}
.chat-msg-bubble.md th {
    background: var(--bg-2);
    font-weight: 600;
    color: var(--text);
    font-size: 0.75rem;
}
.chat-msg-bubble.md td {
    color: var(--text-2);
}

.chat-msg-bubble.md > :first-child { margin-top: 0; }
.chat-msg-bubble.md > :last-child { margin-bottom: 0; }

/* Loading dots */
.chat-typing {
    display: inline-flex; align-items: center; gap: 0.25rem;
    color: var(--text-4);
    padding: 0.375rem 0;
}
.chat-typing > span {
    width: 0.4375rem; height: 0.4375rem;
    background: currentColor;
    border-radius: 50%;
    animation: chat-pulse 1.2s infinite;
}
.chat-typing > span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing > span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-pulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
    30% { opacity: 1; transform: scale(1); }
}

/* Tool cards dentro del mensaje del asistente */
.chat-tools { display: flex; flex-direction: column; gap: 0.375rem; margin-top: 0.5rem; }
.chat-tool {
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg-2);
    overflow: hidden;
    font-size: 0.8125rem;
}
.chat-tool-head {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.4375rem 0.625rem;
    cursor: pointer;
    user-select: none;
}
.chat-tool-head:hover { background: var(--bg-hover); }
.chat-tool-icon {
    width: 1.125rem; height: 1.125rem;
    flex-shrink: 0;
    color: var(--text-3);
}
.chat-tool.running .chat-tool-icon { color: var(--info); animation: spin 1s linear infinite; }
.chat-tool.success .chat-tool-icon { color: var(--ok); }
.chat-tool.error .chat-tool-icon { color: var(--err); }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.chat-tool-name {
    flex: 1; min-width: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-2);
}
.chat-tool-status { font-size: 0.6875rem; color: var(--text-4); }
.chat-tool-toggle { color: var(--text-4); transition: transform 150ms; }
.chat-tool.expanded .chat-tool-toggle { transform: rotate(90deg); }
.chat-tool-body {
    display: none;
    padding: 0 0.625rem 0.625rem;
    border-top: 1px solid var(--border);
}
.chat-tool.expanded .chat-tool-body { display: block; }
.chat-tool-body pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.625rem;
    margin-top: 0.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    line-height: 1.5;
    overflow-x: auto;
    color: var(--text-2);
    max-height: 300px;
    overflow-y: auto;
}
.chat-tool-body .chat-tool-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.5rem;
}

/* Confirm card destructive */
.chat-confirm {
    border: 1px solid var(--warn);
    border-radius: 12px;
    background: var(--warn-bg);
    color: var(--warn-fg);
    padding: 0.875rem;
    margin-top: 0.5rem;
    animation: fadeIn 200ms var(--ease);
}
.chat-confirm-head {
    display: flex; align-items: flex-start; gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.chat-confirm-head .icon { width: 1.125rem; height: 1.125rem; flex-shrink: 0; margin-top: 0.0625rem; }
.chat-confirm-title { font-size: 0.875rem; font-weight: 600; line-height: 1.35; }
.chat-confirm-tool {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    background: rgb(217 119 6 / 0.12);
    border-radius: 5px;
    padding: 0.125rem 0.375rem;
    margin-left: 0.25rem;
}
.chat-confirm-args {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    background: rgb(255 255 255 / 0.55);
    border-radius: 6px;
    padding: 0.5rem 0.625rem;
    margin: 0.5rem 0 0.75rem;
    overflow-x: auto;
    line-height: 1.5;
    white-space: pre;
}
:root.dark .chat-confirm-args { background: rgb(0 0 0 / 0.25); }
.chat-confirm-actions {
    display: flex; justify-content: flex-end; gap: 0.5rem;
}

/* Empty state */
.chat-empty {
    text-align: center;
    padding: 2.5rem 1.25rem;
    color: var(--text-3);
}
.chat-empty-mark {
    width: 3rem; height: 3rem;
    margin: 0 auto 0.875rem;
    background: var(--text);
    color: var(--bg);
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
}
.chat-empty h3 {
    font-size: 1rem; font-weight: 600;
    color: var(--text);
    margin-bottom: 0.375rem;
    letter-spacing: -0.01em;
}
.chat-empty p {
    font-size: 0.875rem;
    line-height: 1.55;
    max-width: 32ch;
    margin: 0 auto 1rem;
}
.chat-suggestions {
    display: flex; flex-wrap: wrap; gap: 0.375rem; justify-content: center;
}
.chat-suggestions .btn { font-size: 0.8125rem; }

/* Footer / input */
.chat-input-area {
    border-top: 1px solid var(--border);
    padding: 0.625rem 0.75rem 0.75rem;
    background: var(--bg-card);
    flex-shrink: 0;
}
.chat-input-wrap {
    position: relative;
    border: 1px solid var(--border-2);
    border-radius: 12px;
    background: var(--bg-card);
    transition: border-color 120ms, box-shadow 120ms;
    overflow: hidden;
}
.chat-input-wrap:focus-within {
    border-color: var(--text);
    box-shadow: 0 0 0 3px var(--ring);
}
.chat-input-wrap textarea {
    display: block;
    width: 100%;
    min-height: 2.75rem;
    max-height: 12rem;
    padding: 0.625rem 0.75rem 0.375rem;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: inherit;
}
.chat-input-wrap textarea::placeholder { color: var(--text-4); }
.chat-input-bar {
    display: flex; align-items: center; gap: 0.375rem;
    padding: 0.25rem 0.375rem 0.25rem 0.5rem;
    border-top: 1px solid transparent;
}
.chat-input-bar-hint {
    flex: 1;
    font-size: 0.6875rem;
    color: var(--text-4);
}
.chat-input-bar-hint kbd {
    background: var(--bg-3);
    border: 1px solid var(--border);
    font-size: 0.625rem;
    height: 1rem;
    padding: 0 0.3125rem;
    margin: 0 0.0625rem;
}

.chat-foot-help {
    margin-top: 0.4375rem;
    font-size: 0.6875rem;
    color: var(--text-4);
    text-align: center;
}

/* Section grids */
.dash-row {
    display: grid;
    gap: 1.125rem;
    margin-bottom: 1.125rem;
}
.dash-row.cols-2 { grid-template-columns: 1fr 1fr; }
.dash-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.dash-row.cols-2-asym { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 1100px) {
    .dash-row.cols-2, .dash-row.cols-3, .dash-row.cols-2-asym { grid-template-columns: 1fr; }
}

/* =============================================================================
   Stock Pro — escaneo, selección masiva, tabla kardex, drawer
   ============================================================================= */

.text-danger { color: var(--err); }

/* ---------- Barra de escaneo / búsqueda rápida ---------- */
.scan-wrap { position: relative; margin-bottom: 1.125rem; }
.scan-input-wrap .input { height: 2.875rem; font-size: 0.95rem; }
.scan-results {
    position: absolute; top: calc(100% + 0.375rem); left: 0; right: 0; z-index: 30;
    background: var(--bg-card); border: 1px solid var(--border-2); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); max-height: 22rem; overflow-y: auto; display: none;
}
.scan-results.show { display: block; animation: fadeIn 140ms var(--ease); }
.scan-row {
    display: flex; align-items: center; gap: 0.875rem; padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border);
}
.scan-row:last-child { border-bottom: 0; }
.scan-row-info { flex: 1; min-width: 0; }
.scan-row-stock { font-weight: 600; white-space: nowrap; }
.scan-row-actions { display: flex; gap: 0.3125rem; }
.scan-row-actions .btn-icon { width: 2rem; height: 2rem; font-size: 1rem; font-weight: 600; }

/* ---------- Checkbox de selección de variante ---------- */
.sel-check { position: relative; display: inline-flex; cursor: pointer; flex-shrink: 0; }
.sel-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.sel-check span {
    width: 1.125rem; height: 1.125rem; border: 1.5px solid var(--border-2); border-radius: 5px;
    display: inline-block; transition: all var(--duration) var(--ease); background: var(--bg);
}
.sel-check input:checked + span {
    background: var(--text); border-color: var(--text);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-size: 0.75rem; background-position: center; background-repeat: no-repeat;
}
:root.dark .sel-check input:checked + span {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}
.inv-variant.is-selected { outline: 2px solid var(--text); outline-offset: 1px; border-radius: var(--radius-sm); }

/* ---------- Barra flotante de acciones masivas ---------- */
.bulk-bar {
    position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(150%);
    z-index: 60; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    background: var(--text); color: var(--bg); padding: 0.625rem 0.875rem;
    border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
    opacity: 0; pointer-events: none; transition: transform 240ms var(--ease), opacity 240ms var(--ease);
    max-width: calc(100vw - 2rem);
}
.bulk-bar.show { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }
.bulk-bar-info { display: flex; align-items: center; gap: 0.5rem; padding-left: 0.375rem; }
.bulk-bar-badge {
    background: var(--bg); color: var(--text); border-radius: 999px; min-width: 1.5rem; height: 1.5rem;
    display: inline-flex; align-items: center; justify-content: center; padding: 0 0.4rem;
    font-weight: 700; font-size: 0.8125rem;
}
.bulk-bar-actions { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.bulk-bar-actions .btn { background: rgb(255 255 255 / 0.1); border-color: transparent; color: var(--bg); }
.bulk-bar-actions .btn:hover { background: rgb(255 255 255 / 0.2); }
:root.dark .bulk-bar-actions .btn { background: rgb(0 0 0 / 0.15); color: var(--bg); }
:root.dark .bulk-bar-actions .btn:hover { background: rgb(0 0 0 / 0.3); }

/* ---------- Tabla de datos (kardex / conteo) ---------- */
.data-table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.data-table thead th {
    position: sticky; top: 0; background: var(--bg-2); z-index: 1;
    text-align: left; font-weight: 600; color: var(--text-3); text-transform: uppercase;
    letter-spacing: 0.04em; font-size: 0.6875rem; padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--border-2);
    white-space: nowrap;
}
.data-table tbody td { padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr.st-diff { background: var(--warn-bg); }
.data-table tbody tr.st-diff:hover { background: var(--warn-bg); }

/* ---------- Badges de tipo de movimiento ---------- */
.mov-badge {
    display: inline-flex; align-items: center; gap: 0.3125rem; padding: 0.1875rem 0.5rem;
    border-radius: 999px; font-size: 0.6875rem; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent;
}
.mov-badge .icon { width: 0.75rem; height: 0.75rem; }
.mov-badge.mov-in  { background: var(--ok-bg); color: var(--ok-fg); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.mov-badge.mov-out { background: var(--err-bg); color: var(--err-fg); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.mov-badge.mov-adj { background: var(--bg-3); color: var(--text-2); border-color: var(--border-2); }

/* ---------- Drawer lateral (kardex por variante) ---------- */
.drawer {
    position: fixed; inset: 0; z-index: 70; background: rgb(0 0 0 / 0.4);
    opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease);
}
.drawer.open { opacity: 1; pointer-events: auto; }
.drawer-panel {
    position: absolute; top: 0; right: 0; height: 100%; width: min(440px, 92vw);
    background: var(--bg-card); border-left: 1px solid var(--border-2); box-shadow: var(--shadow-xl);
    display: flex; flex-direction: column; transform: translateX(100%); transition: transform 280ms var(--ease);
}
.drawer.open .drawer-panel { transform: translateX(0); }
.drawer-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.drawer-head h3 { font-size: 0.95rem; }
.drawer-body { overflow-y: auto; padding: 1rem 1.25rem; flex: 1; }

.kardex { display: flex; flex-direction: column; }
.kardex-item { display: flex; gap: 0.75rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.kardex-item:last-child { border-bottom: 0; }
.kardex-item-body { flex: 1; min-width: 0; }
.kardex-item-main { font-weight: 600; font-size: 0.9rem; }

@media (max-width: 640px) {
    .bulk-bar { left: 0.5rem; right: 0.5rem; transform: translateY(150%); width: auto; max-width: none; }
    .bulk-bar.show { transform: translateY(0); }
    .bulk-bar-actions .btn span { display: none; }
}

/* =============================================================================
   Chat — adjuntos de imagen (visión)
   ============================================================================= */
.chat-attach-row { display: none; gap: 0.5rem; flex-wrap: wrap; padding: 0 0 0.5rem; }
.chat-attach-row.has-items { display: flex; }
.chat-attach-chip {
    position: relative; width: 3.25rem; height: 3.25rem; border-radius: 8px;
    overflow: hidden; border: 1px solid var(--border-2); background: var(--bg-3); flex-shrink: 0;
}
.chat-attach-chip img { width: 100%; height: 100%; object-fit: cover; }
.chat-attach-chip.uploading img { opacity: 0.35; }
.chat-attach-chip button {
    position: absolute; top: 2px; right: 2px; width: 1.15rem; height: 1.15rem; border-radius: 50%;
    background: rgba(0,0,0,0.62); color: #fff; display: flex; align-items: center; justify-content: center; padding: 0;
}
.chat-attach-chip button .icon { width: 0.72rem; height: 0.72rem; }
.chat-attach-spin {
    position: absolute; inset: 0; margin: auto; width: 1.1rem; height: 1.1rem;
    border: 2px solid rgba(255,255,255,0.5); border-top-color: #fff; border-radius: 50%;
    animation: chatspin 0.7s linear infinite;
}
.chat-msg.user .chat-msg-img {
    max-width: 200px; max-height: 200px; border-radius: 10px; margin-bottom: 0.4rem; display: block;
}
.chat-panel.drag { outline: 2px dashed var(--text); outline-offset: -8px; }
@keyframes chatspin { to { transform: rotate(360deg); } }

/* Chat — mini-loader de actividad (reemplaza el spam de recuadros de tools) */
.chat-activity { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; font-size: 0.8125rem; color: var(--text-3); }
.chat-activity-spin {
    width: 0.85rem; height: 0.85rem; flex-shrink: 0; border-radius: 50%;
    border: 2px solid var(--border-2); border-top-color: var(--text-3);
    animation: chatspin 0.7s linear infinite;
}
.chat-activity-label { animation: chatpulse 1.5s ease-in-out infinite; }
.chat-tools-note { font-size: 0.72rem; color: var(--text-4); margin-top: 0.25rem; }
@keyframes chatpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
