/* ============================================================
   SOFTWEBDEV OS · Design System & Layout
   Variables, resets, componentes globales, layout principal
   ============================================================ */

:root {
    /* ============================================================
       Paleta principal: Morado Softwebdev (oficial #7c3aed)
       Coherencia premium · sin neón · sin glassmorphism
       ============================================================ */
    --primary: #7c3aed;
    --primary-hover: #8b5cf6;
    --primary-active: #6d28d9;
    --primary-light: #c4b5fd;
    --primary-bg: rgba(124, 58, 237, 0.12);
    --primary-border: rgba(124, 58, 237, 0.30);

    /* ============================================================
       Superficies & fondo (Dirección C · Oficial background #07070c)
       Nombres canónicos nuevos + alias legacy para compatibilidad
       ============================================================ */
    --background: #07070c;
    --background-2: #0a0a12;
    --surface-1: #10101a;
    --surface-2: #0d0d14;
    --surface-3: #181825;
    --surface-4: #1f1f30;
    --surface-hover: #171725;
    /* Alias legacy (apuntan a nombres canónicos — sin drift) */
    --surface: var(--surface-1);

    /* ============================================================
       Bordes y divisores (nuevo set + alias legacy)
       ============================================================ */
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-default: #222233;
    --border-strong: #37374e;
    --border-hover: #303048;
    /* Alias legacy */
    --border: var(--border-default);

    /* ============================================================
       Tipografía (Dirección C · Poppins primero con fallback)
       Nombres canónicos + alias legacy
       ============================================================ */
    --text-primary: #e8eaf0;
    --text-secondary: #cdd1dc;
    --text-muted: #8d92a6;
    --text-faint: #666a80;
    --text-inverse: #ffffff;
    /* Alias legacy */
    --text:   var(--text-primary);
    --text-2: var(--text-secondary);

    /* Escala tipográfica oficial Dirección C (densidad ERP) */
    --fs-xs:   11px;
    --fs-sm:   12px;
    --fs-base: 14px;
    --fs-md:   15px;
    --fs-lg:   16px;
    --fs-xl:   20px;
    --fs-2xl:  24px;

    /* Pesos tipográficos (Poppins wght 400..800) */
    --fw-regular:   400;
    --fw-medium:    500;
    --fw-semibold:  600;
    --fw-bold:      700;
    --fw-extrabold: 800;

    /* ============================================================
       Estados semánticos (badge / alert / KPI state color)
       Se mantienen 1:1 legacy para compatibilidad
       ============================================================ */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --success-border: rgba(16, 185, 129, 0.30);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --warning-border: rgba(245, 158, 11, 0.30);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --danger-border: rgba(239, 68, 68, 0.30);
    --info: #0ea5e9;
    --info-bg: rgba(14, 165, 233, 0.12);
    --info-border: rgba(14, 165, 233, 0.30);
    --purple: #a855f7;
    --purple-bg: rgba(168, 85, 247, 0.12);
    --purple-border: rgba(168, 85, 247, 0.30);
    --secondary: #6b7280;
    --secondary-bg: rgba(107, 114, 128, 0.15);
    --secondary-border: rgba(107, 114, 128, 0.30);

    /* ============================================================
       Radio (escala 6 · 6/8/12/16/20/full — NO añadir más)
       Recomendación uso oficial:
         input/button  → 8px  (--radius-sm)
         card          → 12px (--radius-md alias --radius)
         modal         → 16px (--radius-lg)
         pill/avatar   → full
       ============================================================ */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius: 12px;         /* alias legacy */
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 999px;

    /* ============================================================
       Sombras (Dirección C · mínimas · sin flotar exagerado)
       shadow-lg y shadow-primary legacy: se redujo intensidad
       4 niveles reales xs / sm / md / lg + primary
       ============================================================ */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.22);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.26);
    --shadow:    var(--shadow-md);       /* alias legacy */
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.32);
    --shadow-primary: 0 6px 18px rgba(124, 58, 237, 0.22);

    /* ============================================================
       Espaciados (escala múltiplo 4 · 9 tokens)
       4 / 8 / 12 / 16 / 20 / 24 / 32 / 40 / 48
       NO añadir 6/10/14/18/22/28/36; migrar inline hacia escala
       ============================================================ */
    --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;
    --sp-4: 16px;  --sp-5: 20px;  --sp-6: 24px;
    --sp-7: 32px;  --sp-8: 40px;  --sp-9: 48px;

    /* ============================================================
       Layout (sin cambios)
       ============================================================ */
    --sidebar-w: 260px;
    --sidebar-w-collapsed: 76px;
    --header-h: 64px;
    --drawer-w: 400px;

    /* ============================================================
       Fuentes (Poppins ADN Softy oficial)
       Fallback incondicional a stack system-ui
       ============================================================ */
    --font-sans: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

    color-scheme: dark;
}

/* ========================================
   RESET
   ======================================== */
*,*::before,*::after { box-sizing:border-box; }
html, body { height:100%; }
body {
    margin:0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { color: #fff; }
img, svg { display: block; max-width: 100%; }
input, button, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
h1,h2,h3,h4,h5,h6 { margin: 0 0 .5em; color: #fff; font-weight: 600; letter-spacing: -0.01em;}
h1 { font-size: 26px; line-height: 1.2;}
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 1em;}
ul,ol { margin: 0; padding-left: 1.2em;}
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-5) 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; border: 2px solid transparent; }

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1;
    white-space: nowrap;
    transition: all .15s ease;
    user-select: none;
    border: 1px solid transparent;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 13px 20px; font-size: 14.5px; }
.btn-icon { padding: 10px; width: 38px; height: 38px; border-radius: 10px; }
.btn-icon.btn-sm { padding: 6px; width: 30px; height: 30px; border-radius: 8px; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(124,58,237,.25);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); box-shadow: var(--shadow-primary); }
.btn-primary:active:not(:disabled) { transform: translateY(0); filter: brightness(.95); }

.btn-secondary {
    background: var(--surface-3);
    color: var(--text);
    border-color: var(--border-hover);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-4); border-color: var(--border-strong); color: #fff; }

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

.btn-success {
    background: var(--success-bg);
    color: #6ee7b7;
    border-color: var(--success-border);
}
.btn-success:hover:not(:disabled) { background: var(--success); color: #fff; border-color: var(--success); }

.btn-warning {
    background: var(--warning-bg);
    color: #fcd34d;
    border-color: var(--warning-border);
}
.btn-warning:hover:not(:disabled) { background: var(--warning); color: #000; border-color: var(--warning); }

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border-hover);
}
.btn-outline:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }

.btn-ghost {
    background: transparent; color: var(--text-muted);
}
.btn-ghost:hover { color: #fff; background: var(--surface-hover); }

/* ========================================
   FORMS · Inputs / Selects / Textareas
   ======================================== */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}
.form-label-row { display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
.form-label-row .form-label { margin:0; }
.link-muted { color: var(--primary-light); font-size:12.5px; font-weight:500; }
.link-muted:hover { color: #fff; }

.form-control {
    display: block;
    width: 100%;
    padding: 10.5px 13px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all .15s;
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:hover { border-color: var(--border-hover); }
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-control:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; opacity:.7; }

textarea.form-control { min-height: 96px; resize: vertical; line-height: 1.5; }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%238b8fa0'><path d='M8 11L3 6h10z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}
select.form-control[multiple] { background: none; padding: 6px; }

.input-group { display:flex; align-items:stretch; }
.input-group > * + * { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group > :first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .form-control + .btn, .input-group .btn + .form-control { margin-left:-1px; }

.input-icon { position: relative; }
.input-icon > svg, .input-icon > .i { position:absolute; left:12px; top:50%; transform:translateY(-50%); color: var(--text-faint); pointer-events:none; }
.input-icon > input { padding-left: 40px; }
.input-icon-right > svg, .input-icon-right > .i { left:auto; right:12px;}
.input-icon-right > input { padding-left:13px; padding-right: 40px; }

.field-hint { font-size: 12px; color: var(--text-muted); margin-top:5px; }
.field-error { color: #fca5a5; font-size: 12.5px; margin-top: 6px; display:flex; align-items:flex-start; gap:6px;}
.field-error::before { content:'⚠'; flex:0 0 auto; margin-top:1px;}
.form-control.has-error { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }

/* ========================================
   CHECKBOX · RADIO
   ======================================== */
.form-check { display:flex; align-items:center; gap: 9px; cursor:pointer; padding: 4px 0; font-size: 13.5px; color: var(--text-2);}
.form-check input[type=checkbox], .form-check input[type=radio] { display:none; }
.form-check input[type=checkbox] + .cb,
.form-check input[type=radio] + .cb {
    display:inline-flex; align-items:center; justify-content:center;
    width:18px; height:18px; border-radius:5px; border:1.5px solid var(--border-hover);
    background: var(--surface-2); transition: all .15s; color:transparent; font-size: 12px;
}
.form-check input[type=radio] + .cb { border-radius: 50%; }
.form-check input[type=radio] + .cb::after { content:''; width: 8px; height:8px; border-radius:50%; background: #fff; transform: scale(0); transition: transform .15s;}
.form-check:hover input + .cb { border-color: var(--border-strong); }
.form-check input:checked + .cb { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 3px var(--primary-bg); }
.form-check input:checked[type=radio] + .cb::after { transform: scale(1); background:#fff; }
.form-check input:checked[type=radio] + .cb { color: transparent; }

.form-switch { position: relative; display:inline-block; width:38px; height:22px; }
.form-switch input { opacity:0; width:0; height:0; }
.form-switch .sw { position:absolute; inset:0; background: var(--surface-4); border-radius:999px; cursor:pointer; transition:.2s; }
.form-switch .sw::before { content:''; position:absolute; width:16px; height:16px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.2s; }
.form-switch input:checked + .sw { background: var(--primary); }
.form-switch input:checked + .sw::before { transform:translateX(16px); }

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color .15s;
}
.card-hover:hover { border-color: var(--border-hover); transform: translateY(-2px); transition: all .2s ease; box-shadow: var(--shadow);}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.card-title { margin: 0; font-size: 16px; font-weight: 600; }
.card-subtitle { margin: 4px 0 0 0; font-size: 13px; color: var(--text-muted); }
.card-body { padding: var(--sp-6); }
.card-footer {
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    display:flex;
    gap: 10px;
    justify-content: flex-end;
}
.card-actions { display:flex; align-items:center; gap:8px; flex-wrap: wrap; }

/* Stat card */
.stat-card {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 14px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all .18s;
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow);}
.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-sm);
    display:flex; align-items:center; justify-content:center;
    background: var(--primary-bg);
    color: var(--primary-light);
    flex: 0 0 52px;
}
.stat-icon.primary { background: var(--primary-bg); color: var(--primary-light); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-bg); color: var(--danger); }
.stat-icon.info    { background: var(--info-bg); color: var(--info); }
.stat-icon.purple  { background: var(--purple-bg); color: var(--purple); }
.stat-icon svg { width: 24px; height: 24px; stroke-width: 2; }

.stat-content { display:flex; flex-direction:column; min-width:0; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; text-transform: none; letter-spacing: 0;}
.stat-value { margin-top: 4px; font-size: 24px; font-weight: 700; color: #fff; letter-spacing: -0.01em; line-height:1.2;}
.stat-delta { margin-top: 8px; display:flex; align-items:center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-muted);}
.stat-delta.up { color: #6ee7b7; }
.stat-delta.down { color: #fca5a5; }

/* ========================================
   TABLES
   ======================================== */
.table-wrap { overflow-x:auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.table { width:100%; border-collapse: collapse; font-size: 13.5px; }
.table thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: .02em;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.selected { background: var(--primary-bg); }
.table.table-sm thead th { padding: 10px 14px; }
.table.table-sm tbody td { padding: 11px 14px; font-size:13px;}
.table .actions { display:flex; align-items:center; gap:4px; justify-content:flex-end;}
.table .cell-num { text-align:right; font-variant-numeric: tabular-nums; font-weight:500;}
.table .cell-center { text-align:center; }
.table .no-wrap { white-space: nowrap; }
.cell-title { display:flex; flex-direction:column; gap:2px;}
.cell-title .t { font-weight:600; color:#fff; }
.cell-title .s { font-size: 12px; color: var(--text-muted);}

.row-actions-btn {
    display: inline-flex;
    align-items:center; justify-content:center;
    width:30px; height:30px;
    border-radius: 8px;
    color: var(--text-muted);
    transition: all .12s;
    cursor: pointer;
    border: 0;
    background: transparent;
}
.row-actions-btn:hover { background: var(--surface-4); color: #fff; }

.empty-table { padding: 70px 20px; text-align:center; color: var(--text-muted); }
.empty-table .empty-icon { width: 64px; height: 64px; margin: 0 auto 16px; color: var(--border); }
.empty-table h3 { color: var(--text-2); font-size: 16px; }
.empty-table p { font-size: 13px; margin: 6px 0 20px; }

/* ========================================
   BADGES · STATES
   ======================================== */
.badge {
    display:inline-flex;
    align-items:center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 999px;
    line-height: 1.5;
    letter-spacing: .01em;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge::before { content: ''; width:6px; height:6px; border-radius:50%; background: currentColor; opacity:.85; }
.badge.success { background: var(--success-bg); color: #6ee7b7; border-color: var(--success-border); }
.badge.warning { background: var(--warning-bg); color: #fcd34d; border-color: var(--warning-border); }
.badge.danger  { background: var(--danger-bg);  color: #fca5a5; border-color: var(--danger-border); }
.badge.info    { background: var(--info-bg);    color: #7dd3fc; border-color: var(--info-border); }
.badge.primary { background: var(--primary-bg); color: #c4b5fd; border-color: var(--primary-border); }
.badge.purple  { background: var(--purple-bg);  color: #d8b4fe; border-color: var(--purple-border); }
.badge.secondary { background: var(--secondary-bg); color: #cbd5e1; border-color: var(--secondary-border);}
.badge.badge-lg { padding: 6px 12px; font-size: 12.5px;}
.badge.badge-sm { padding: 3px 8px; font-size: 11px;}
.badge.badge-outline { background: transparent; }
.badge.dotless::before { display:none; }

/* ========================================
   AVATARS
   ======================================== */
.avatar {
    display:inline-flex; align-items:center; justify-content:center;
    border-radius:999px;
    font-weight: 700;
    color:#fff;
    background: var(--primary);
    overflow:hidden;
    flex-shrink: 0;
}
.avatar-xs { width: 22px; height: 22px; font-size: 10px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11.5px; }
.avatar-md { width: 36px; height: 36px; font-size: 13.5px; }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }
.avatar-xl { width: 72px; height: 72px; font-size: 24px; }
.avatar img { width: 100%; height: 100%; object-fit: cover;}

/* ========================================
   TABS
   ======================================== */
.tabs { display:flex; gap:4px; border-bottom: 1px solid var(--border); margin-bottom: 0; overflow-x:auto;}
.tab {
    padding: 10px 16px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    border: 0;
    background: transparent;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: all .12s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }
.tab.badge-tab { display: inline-flex; align-items: center; gap: 8px; }

/* ========================================
   BREADCRUMBS
   ======================================== */
.breadcrumbs {
    display: flex; align-items: center; gap: 6px;
    font-size: 12.5px; color: var(--text-muted);
    margin-bottom: var(--sp-5);
}
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: #fff;}
.breadcrumbs .sep { opacity:.5; }
.breadcrumbs .current { color: var(--text); font-weight: 600;}

/* ========================================
   ALERTS · FLASH NOTIFICATIONS
   ======================================== */
.alert {
    display: flex; align-items:flex-start; gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    margin-bottom: 16px;
    font-size: 13.5px;
}
.alert .ic { margin-top:1px; flex: 0 0 auto;}
.alert.success { background: var(--success-bg); color: #a7f3d0; border-color: var(--success-border); }
.alert.danger  { background: var(--danger-bg);  color: #fecaca; border-color: var(--danger-border); }
.alert.warning { background: var(--warning-bg); color: #fde68a; border-color: var(--warning-border); }
.alert.info    { background: var(--info-bg);    color: #bae6fd; border-color: var(--info-border); }
.alert.primary { background: var(--primary-bg); color: #ddd6fe; border-color: var(--primary-border); }

.toast-container {
    position: fixed; top: 80px; right: 24px; z-index: 9999;
    display: flex; flex-direction: column; gap: 10px; max-width: 380px;
}
.toast {
    background: var(--surface); border: 1px solid var(--border);
    padding: 14px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    display: flex; align-items:flex-start; gap: 12px; min-width: 300px;
    animation: toastIn .25s ease;
}
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity:1;} }
.toast .t { font-weight: 700; font-size: 13.5px; color: #fff; margin-bottom: 2px; }
.toast .m { font-size: 13px; color: var(--text-2); }

/* ========================================
   PAGINATION
   ======================================== */
.pagination-wrap {
    display:flex;
    justify-content: space-between;
    align-items:center;
    padding: 16px;
    border-top: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}
.pagination-info { color: var(--text-muted); font-size: 12.5px; }
.pagination { display:flex; align-items:center; gap: 4px; flex-wrap: wrap; }
.page-btn {
    display:inline-flex; align-items:center; justify-content:center;
    min-width: 34px; height: 34px; padding: 0 10px;
    border-radius: 8px; background: var(--surface-3);
    color: var(--text); border: 1px solid var(--border);
    font-size: 13px; font-weight: 600; cursor:pointer; transition: all .12s;
}
.page-btn:hover:not(:disabled) { background: var(--surface-4); border-color: var(--border-hover); color:#fff;}
.page-btn.active { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color:#fff; border-color: transparent; box-shadow: 0 2px 6px rgba(124,58,237,.3);}
.page-btn:disabled { opacity:.4; cursor: not-allowed; }
.per-page { display:flex; align-items:center; gap:8px; font-size:12.5px; color: var(--text-muted);}
.per-page select { padding: 6px 10px; }

/* ========================================
   DROPDOWNS (menu)
   ======================================== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute;
    z-index: 60;
    top: calc(100% + 8px); right: 0;
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-5px);
    transition: all .15s;
}
.dropdown-menu[data-open="1"], .dropdown.open > .dropdown-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    color: var(--text-2);
    border-radius: 8px;
    font-size: 13.5px;
    cursor: pointer;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
}
.dropdown-item:hover { background: var(--surface-hover); color: #fff; }
.dropdown-item.danger { color: #fca5a5; }
.dropdown-item.danger:hover { background: var(--danger-bg); }
.dropdown-item svg { width: 16px; height:16px; color: var(--text-faint); flex-shrink:0; }
.dropdown-item.danger svg { color:#fca5a5;}
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 4px;}

/* ========================================
   MODAL
   ======================================== */

/* ---------- ESTRUCTURA A (antigua: .modal-backdrop > .modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    opacity: 0; pointer-events: none;
    transition: opacity .2s;
}
.modal-backdrop[data-open="1"] { opacity: 1; pointer-events: auto; }
.modal-backdrop > .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: translateY(10px) scale(.98);
    transition: transform .2s;
    overflow: hidden;
}
.modal-backdrop[data-open="1"] > .modal { transform: none; }

/* ---------- ESTRUCTURA B (nueva): .modal > .modal-overlay + .modal-card ---------- */
.modal:has(> .modal-overlay) {
    position: fixed; inset: 0;
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    opacity: 0; pointer-events: none;
    transition: opacity .2s;
    /* colisión limpia: NO hereda estilos de panel del antiguo .modal genérico */
    background: transparent;
    border: none;
    border-radius: 0;
    max-width: none;
    max-height: none;
    box-shadow: none;
    transform: none;
    overflow: visible;
    flex-direction: row;
    width: auto;
}
.modal[data-open="1"]:has(> .modal-overlay) {
    opacity: 1; pointer-events: auto;
}
.modal-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    z-index: 0;
}
.modal > .modal-card {
    position: relative;
    z-index: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: translateY(10px) scale(.98);
    transition: transform .2s;
    overflow: hidden;
}
.modal[data-open="1"]:has(> .modal-overlay) > .modal-card {
    transform: none;
}

/* Clases de tamaño (aplican a ambos paneles: .modal y .modal-card */
.modal-backdrop > .modal.modal-lg, .modal > .modal-card.modal-lg { max-width: 800px; }
.modal-backdrop > .modal.modal-xl, .modal > .modal-card.modal-xl { max-width: 1100px; }

/* Header / body / footer — compartidos */
.modal-header {
    display:flex; align-items:center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.modal-header h3, .modal-title { margin: 0; font-size: 17px; font-weight: 600; }
.modal-subtitle { margin-top: 3px; font-size: 13px; color: var(--text-muted); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer {
    display:flex; justify-content: flex-end; gap: 10px;
    padding: 16px 22px; border-top: 1px solid var(--border);
    background: var(--surface-2);
}

/* ========================================
   TOOLTIPS
   ======================================== */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%; transform: translateX(-50%);
    background: var(--surface-4);
    color: #fff;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 7px;
    white-space: nowrap;
    z-index: 200;
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
}

/* ========================================
   LOADERS · SPINNER
   ======================================== */
.spinner {
    display:inline-block;
    width: 18px; height:18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
.spinner.lg { width: 28px; height: 28px; border-width: 3px; }
.spinner.white { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); }}

.loader-overlay {
    position: fixed; inset:0; background: rgba(7,7,12,.8);
    display:none; align-items:center; justify-content:center;
    z-index: 9999;
}
.loader-overlay.active { display: flex; }
.loader-overlay .spinner { width: 48px; height:48px; border-width: 4px;}

.skeleton {
    background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-4) 50%, var(--surface-3) 100%);
    background-size: 200% 100%;
    animation: skeleton 1.2s infinite linear;
    border-radius: var(--radius-sm);
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ========================================
   PAGE HEADER
   ======================================== */
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 20px; margin-bottom: 22px;
    flex-wrap: wrap;
}
.page-header .page-title-wrap h1 { margin: 0 0 4px 0;}
.page-header .page-title-wrap p { margin: 0; color: var(--text-muted); font-size: 13.5px;}

.filters-bar {
    display: grid;
    grid-template-columns: minmax(240px, 1.4fr) repeat(3, minmax(180px, 1fr)) auto;
    gap: 10px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
@media (max-width: 900px) {
    .filters-bar { grid-template-columns: 1fr 1fr; }
}

/* ========================================
   SPLIT CONTENT (table + drawer derecho)
   ======================================== */
.app-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 0;
    gap: 0;
    transition: grid-template-columns .25s;
}
.app-split.drawer-open {
    grid-template-columns: minmax(0, 1fr) var(--drawer-w);
    gap: 18px;
}
@media (max-width: 1180px) {
    .app-split.drawer-open {
        grid-template-columns: 1fr;
    }
}

/* Drawer derecho detalle */
.drawer-detail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    height: calc(100vh - var(--header-h) - 50px);
    position: sticky;
    top: calc(var(--header-h) + 16px);
    overflow-y: auto;
    display: none;
}
.app-split.drawer-open .drawer-detail { display: block; }
.drawer-header {
    display:flex; align-items:flex-start; justify-content: space-between; gap: 10px;
    padding-bottom: 16px; margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.drawer-header h3 { margin: 0 0 4px; font-size: 17px; }
.drawer-header .code { font-weight: 700; color: var(--primary-light); font-size: 16px; margin: 0 0 6px;}
.drawer-actions { display:flex; align-items:center; gap: 6px; flex-wrap: wrap; margin: 14px 0 20px;}
.drawer-actions .btn { flex: 1; min-width: 0; flex-direction: column; gap: 4px; padding: 10px 6px; font-size: 11.5px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);}
.drawer-actions .btn:hover { background: var(--surface-4); color:#fff; }
.drawer-actions .btn svg { width: 18px; height: 18px; }
.drawer-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.drawer-section:first-of-type { border-top: 0; padding-top: 0; margin-top:0;}
.drawer-section h4 {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--text-muted);
    text-transform: uppercase;
    margin: 0 0 12px;
}
.info-row {
    display:flex; justify-content:space-between; align-items:flex-start; gap:12px;
    padding: 7px 0;
    font-size: 13px;
}
.info-row .label { color: var(--text-muted); }
.info-row .val { color: var(--text); font-weight: 500; text-align:right;}
.info-row.link .val { color: var(--primary-light); font-weight: 600; cursor:pointer; }
.client-chip {
    display:flex; align-items:center; gap: 10px; padding: 12px 0;
}
.client-chip .info { min-width: 0; display:flex; flex-direction:column; gap: 2px;}
.client-chip .info .n { color:#fff; font-weight: 600; font-size: 14px; }
.client-chip .info .c { color: var(--text-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis;}
.resumen-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-top: 10px;
}
.resumen-box .info-row .val.big { font-size: 17px; color: var(--primary-light); font-weight: 700;}
.resumen-box .info-row .val.success { color: var(--success); }
.resumen-box .info-row .val.danger { color: var(--danger); }

/* ========================================
   APP LAYOUT GENERAL
   ======================================== */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    transition: grid-template-columns .25s;
}
.app.sidebar-collapsed {
    grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}
@media (max-width: 1080px) {
    .app { grid-template-columns: 0 1fr; }
    .app.sidebar-collapsed { grid-template-columns: 0 1fr; }
    .app.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }
    .backdrop-mobile { display:none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40;}
    .app.sidebar-mobile-open .backdrop-mobile { display: block;}
}

/* SIDEBAR */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--background-2);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 50;
    transition: transform .25s, width .25s;
}
.app.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
@media (max-width: 1080px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w); box-shadow: var(--shadow-lg);}
}

.sidebar-logo {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items:center; gap: 12px;
    height: var(--header-h);
    flex-shrink: 0;
}
.app.sidebar-collapsed .sidebar-logo { padding: 18px 14px; justify-content: center;}
.sidebar-logo .logo-mark {
    width: 38px; height: 38px; border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    display:flex; align-items:center; justify-content:center;
    font-weight: 900; color: #fff;
    letter-spacing: -1px;
    font-size: 19px;
    box-shadow: 0 4px 12px rgba(124,58,237,.35);
    flex-shrink:0;
}
.sidebar-logo .logo-mark::before { content: 'S'; }
.sidebar-logo .logo-text { display:flex; flex-direction: column; min-width: 0;}
.app.sidebar-collapsed .sidebar-logo .logo-text { display: none;}
.sidebar-logo .logo-text .t1 { font-size: 16px; font-weight: 800; color: #fff; letter-spacing: -.01em;}
.sidebar-logo .logo-text .t1 .accent { color: var(--primary-light);}
.sidebar-logo .logo-text .t2 { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; font-weight: 500;}
.badge-os {
    display: inline-flex;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 5px;
    background: var(--primary);
    color: #fff;
    vertical-align: middle;
    margin-left: 3px;
    letter-spacing: .04em;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
}
.nav-section-title {
    padding: 14px 14px 6px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .1em;
}
.app.sidebar-collapsed .nav-section-title { text-align:center; padding: 14px 0 6px; font-size: 9.5px;}
.nav-link {
    display:flex; align-items:center; gap: 12px;
    padding: 10px 14px;
    color: var(--text-2);
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 10px;
    margin: 1px 0;
    position: relative;
    transition: all .12s;
    cursor: pointer;
}
.nav-link:hover { background: var(--surface-hover); color: #fff; }
.nav-link.active {
    background: linear-gradient(135deg, rgba(124,58,237,.22), rgba(147,51,234,.12));
    color: #c4b5fd;
    box-shadow: inset 2px 0 0 var(--primary);
    font-weight: 600;
}
.nav-link .nav-ic {
    width: 20px; height: 20px; flex: 0 0 20px;
    color: currentColor; display:flex; align-items:center; justify-content:center;
}
.nav-link .nav-ic svg { width: 100%; height: 100%; stroke-width: 2;}
.nav-link .nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app.sidebar-collapsed .nav-link { justify-content: center; padding: 12px; }
.app.sidebar-collapsed .nav-link .nav-label,
.app.sidebar-collapsed .nav-link .nav-count { display: none; }
.nav-count {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--danger-bg);
    color: #fca5a5;
}

.nav-group {
    position: relative;
    margin: 1px 0;
}
.nav-group-toggle {
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
}
.nav-group[data-open="1"] > .nav-group-toggle .nav-chevron {
    transform: rotate(90deg);
}
.nav-chevron {
    width: 16px; height: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    margin-left: 4px;
    transition: transform .18s ease;
    flex: 0 0 auto;
}
.nav-chevron svg { width: 100%; height: 100%; stroke-width: 2; }
.nav-submenu {
    display: block;
    max-height: 0;
    overflow: hidden;
    transition: max-height .22s ease, padding .22s ease;
    padding: 0 0 0 0;
}
.nav-group[data-open="1"] > .nav-submenu {
    max-height: 480px;
    padding: 2px 0 6px 0;
}
.nav-sub-link {
    padding-left: 46px;
    font-size: 13px;
    font-weight: 500;
    margin: 1px 0;
}
.nav-sub-link .nav-ic {
    width: 16px; height: 16px; flex: 0 0 16px;
    opacity: .85;
}
.app.sidebar-collapsed .nav-group-toggle .nav-label,
.app.sidebar-collapsed .nav-chevron,
.app.sidebar-collapsed .nav-submenu { display: none; }

.softy-panel {
    margin: auto 10px 14px;
    border-radius: var(--radius);
    padding: 14px;
    background:
        radial-gradient(circle at top left, rgba(168,85,247,.18), transparent 60%),
        linear-gradient(180deg, var(--surface), var(--surface-3));
    border: 1px solid var(--primary-border);
    position: relative;
    overflow: hidden;
}
.app.sidebar-collapsed .softy-panel { padding: 10px; text-align: center; }
.softy-hello {
    display:flex; align-items:center; gap: 10px; margin-bottom: 8px;
}
.app.sidebar-collapsed .softy-hello { justify-content:center;}
.softy-emoji {
    width: 44px; height: 44px;
    display:flex; align-items:center; justify-content:center;
    font-size: 30px;
    background: var(--primary-bg);
    border: 1px solid var(--primary-border);
    border-radius: 14px;
    flex-shrink: 0;
    box-shadow: inset 0 -4px 0 rgba(0,0,0,.25);
}
.app.sidebar-collapsed .softy-emoji { width: 40px; height: 40px; font-size: 26px;}
.softy-title { font-size: 13.5px; color: #fff; font-weight: 700;}
.softy-title .w { color: var(--primary-light); }
.softy-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px;}
.app.sidebar-collapsed .softy-title, .app.sidebar-collapsed .softy-sub { display:none; }
.softy-items {
    list-style: none;
    padding: 0; margin: 12px 0;
}
.app.sidebar-collapsed .softy-items { display:none;}
.softy-items li {
    font-size: 12px;
    color: var(--text-2);
    padding: 4px 0;
    display: flex; gap: 8px;
    align-items: flex-start;
}
.softy-items li::before { content: '•'; color: var(--primary-light); font-weight: 700; margin-top: -1px;}
.softy-btn {
    display: flex; align-items:center; justify-content: space-between;
    padding: 10px 12px;
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    font-weight: 700;
    font-size: 12.5px;
    border-radius: 9px;
    cursor: pointer;
    border: 0;
}
.app.sidebar-collapsed .softy-btn { justify-content:center; padding: 8px; border-radius: 10px;}
.app.sidebar-collapsed .softy-btn span { display:none;}
.softy-btn::after { content: '→'; font-weight: 700;}
.app.sidebar-collapsed .softy-btn::after { content: '→'; font-size: 16px;}

/* MAIN WRAPPER */
.main {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* HEADER */
.header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--header-h);
    padding: 0 22px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
    background: rgba(10, 10, 18, .9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.header-left { display:flex; align-items:center; gap: 12px;}
.sidebar-toggle {
    width: 38px; height:38px;
    display:flex; align-items:center; justify-content:center;
    border-radius: 10px;
    color: var(--text-muted);
    transition: all .12s;
    cursor: pointer;
    border: 0;
}
.sidebar-toggle:hover { background: var(--surface-hover); color:#fff; }
.sidebar-toggle svg { width: 20px; height:20px;}

.header-search {
    position: relative;
    max-width: 520px;
    width: 100%;
    justify-self: center;
}
.header-search .q-ic {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-faint); width: 16px; height: 16px;
}
.header-search input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13.5px;
    color: var(--text);
    transition: all .15s;
}
.header-search input:hover { border-color: var(--border-hover);}
.header-search input:focus { outline: none; background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.header-search input::placeholder { color: var(--text-faint); }
@media (max-width: 720px) {
    .header-search { display: none; }
}

.header-right { display:flex; align-items:center; gap: 10px; justify-self: end;}
.header-btn {
    width: 40px; height: 40px;
    position: relative;
    display:flex; align-items:center; justify-content:center;
    border-radius: 10px;
    color: var(--text-2);
    transition: all .12s;
    cursor: pointer;
    border: 0;
}
.header-btn:hover { background: var(--surface-hover); color:#fff;}
.header-btn svg { width: 20px; height: 20px;}
.header-btn .badge-dot {
    position: absolute; top: 8px; right: 8px;
    width: 16px; height: 16px;
    background: var(--danger); color:#fff; border-radius: 999px;
    font-size: 10px; font-weight: 700;
    display:flex; align-items:center; justify-content:center;
    border: 2px solid var(--background-2);
    line-height: 1;
}

.user-menu-wrap { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 12px; cursor: pointer; transition: background .12s;}
.user-menu-wrap:hover { background: var(--surface-hover); }
.user-menu-wrap .info { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.user-menu-wrap .info .u-n { font-size: 13px; font-weight: 600; color:#fff; }
.user-menu-wrap .info .u-r { font-size: 11.5px; color: var(--text-muted);}
@media (max-width: 760px) {
    .user-menu-wrap .info { display: none;}
    .header { padding: 0 14px;}
}

/* CONTENT WRAP */
.content {
    flex: 1 1 auto;
    padding: 24px 28px 40px;
    max-width: 100%;
}
@media (max-width: 760px) {
    .content { padding: 16px; }
}

.page-grid {
    display: grid;
    gap: 18px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.two-col { display:grid; grid-template-columns: 2fr 1fr; gap: 18px; }
@media (max-width: 1000px) {
    .two-col { grid-template-columns: 1fr; }
}

/* ========================================
   UTILITIES
   ======================================== */
.d-flex { display:flex !important;}
.d-grid { display:grid !important;}
.d-none { display:none !important;}
.d-block { display:block !important;}
.d-inline { display:inline !important;}
.align-center { align-items:center;}
.justify-between { justify-content: space-between;}
.justify-center { justify-content: center;}
.justify-end { justify-content: flex-end;}
.flex-col { flex-direction: column;}
.flex-1 { flex:1; min-width:0;}
.flex-wrap { flex-wrap: wrap;}
.gap-1 { gap: 4px;} .gap-2 { gap: 8px;} .gap-3 { gap: 12px;}
.gap-4 { gap: 16px;} .gap-5 { gap: 20px;} .gap-6 { gap: 24px;}
.m-0 { margin:0 !important;} .m-auto { margin: auto;}
.mt-0 { margin-top: 0 !important;} .mt-1 { margin-top: 4px;} .mt-2 { margin-top: 8px;}
.mt-3 { margin-top: 12px;} .mt-4 { margin-top: 16px;} .mt-5 { margin-top: 20px;} .mt-6 { margin-top: 24px;}
.mb-0 { margin-bottom: 0;} .mb-1 { margin-bottom: 4px;} .mb-2 { margin-bottom: 8px;}
.mb-3 { margin-bottom: 12px;} .mb-4 { margin-bottom: 16px;} .mb-5 { margin-bottom: 20px;} .mb-6 { margin-bottom: 24px;}
.ms-auto { margin-left: auto;}
.p-0 { padding: 0 !important;}
.w-100 { width: 100%;} .w-auto { width:auto;}
.h-100 { height: 100%;}
.text-center { text-align:center;} .text-right { text-align:right;}
.text-left { text-align:left;}
.text-muted { color: var(--text-muted) !important;}
.text-primary { color: var(--primary-light) !important;}
.text-success { color: var(--success) !important;}
.text-warning { color: var(--warning) !important;}
.text-danger  { color: var(--danger) !important;}
.text-info    { color: var(--info) !important;}
.text-white   { color: #fff !important;}
.text-xs { font-size: 11px;} .text-sm { font-size: 12.5px;}
.text-base { font-size: 14px;} .text-lg { font-size: 16px;} .text-xl { font-size: 20px;}
.font-400 { font-weight: 400;} .font-500 { font-weight: 500;}
.font-600 { font-weight: 600;} .font-700 { font-weight: 700;}
.overflow-auto { overflow:auto;}
.truncate { overflow:hidden; text-overflow: ellipsis; white-space: nowrap;}
.tabular { font-variant-numeric: tabular-nums;}

.grid-2 { display:grid; grid-template-columns: 1fr 1fr; gap: 14px;}
.grid-3 { display:grid; grid-template-columns: repeat(3, 1fr); gap: 14px;}
.grid-4 { display:grid; grid-template-columns: repeat(4, 1fr); gap: 14px;}
@media (max-width: 900px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr;}
}

/* ============================================================
   13E-B · CALENDARIO OPERATIVO V1
   Prefijo aislado: calendar-*  (0 side effects sobre resto de módulos)
   ============================================================ */
.calendar-filter-bar {
    display:flex; gap:8px; flex-wrap:wrap;
    margin-bottom:14px;
}
.calendar-dow {
    display:grid; grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}
.calendar-dow-cell {
    padding: 8px 6px;
    text-align:center;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.calendar-grid {
    display:grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(118px, auto);
    gap: 2px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.calendar-cell {
    background: var(--surface);
    padding: 6px 7px 7px;
    display:flex; flex-direction: column;
    min-height: 118px;
    overflow: hidden;
    position: relative;
}
.calendar-cell-out {
    background: var(--surface-2);
}
.calendar-cell-out .calendar-cell-day {
    color: var(--text-faint);
}
.calendar-cell-today {
    box-shadow: inset 0 0 0 2px var(--primary);
    background: linear-gradient(180deg, rgba(124,58,237,.07), transparent 40%), var(--surface);
}
.calendar-cell-head {
    display:flex; align-items:center; justify-content: space-between;
    margin-bottom: 4px;
}
.calendar-cell-day {
    font-size: 12.5px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}
.calendar-cell-today .calendar-cell-day {
    background: var(--primary);
    color: #fff;
    width: 22px; height: 22px;
    border-radius: 999px;
    display: inline-flex; align-items:center; justify-content:center;
    font-size: 11.5px;
}
.calendar-cell-count {
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    line-height: 1;
}
.calendar-cell-body {
    display:flex; flex-direction:column; gap:3px;
    flex: 1 1 auto;
    min-width: 0;
}
.calendar-ev {
    display:flex; flex-direction:column; gap:2px;
    padding: 3px 6px;
    border-radius: 6px;
    border-left: 3px solid transparent;
    background: var(--surface-3);
    font-size: 11.5px;
    line-height: 1.25;
    min-width:0;
}
.calendar-ev-tarea {
    background: rgba(124,58,237,.12);
    border-left-color: var(--primary);
}
.calendar-ev-proyecto {
    background: rgba(59,130,246,.12);
    border-left-color: var(--info, #3b82f6);
}
.calendar-ev-cotizacion {
    background: rgba(245,158,11,.12);
    border-left-color: var(--warning);
}
.calendar-ev-vencido {
    background: rgba(239,68,68,.12);
    border-left-color: var(--danger);
}
.calendar-ev-text {
    display:block;
    color: #fff;
    overflow:hidden; text-overflow: ellipsis; white-space: nowrap;
}
.calendar-ev-link {
    text-decoration:none;
    display:block;
    color: inherit;
}
.calendar-ev-link:hover .calendar-ev-text {
    color: #fff;
    text-decoration: underline;
    text-decoration-color: rgba(255,255,255,.4);
}
.calendar-badge {
    display:inline-block;
    align-self: flex-start;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.calendar-badge-danger {
    background: var(--danger);
    color:#fff;
}
.calendar-more {
    margin-top: 2px;
}
.calendar-more > summary {
    list-style: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-light);
    background: var(--primary-bg);
    padding: 2px 6px;
    border-radius: 5px;
    display:inline-block;
    align-self: flex-start;
}
.calendar-more > summary::-webkit-details-marker { display:none; }
.calendar-more[open] > summary { margin-bottom: 3px; }
.calendar-more-list {
    display:flex; flex-direction:column; gap:3px;
}
.calendar-empty-hint {
    text-align:center;
    padding: 16px 0 4px;
    color: var(--text-muted);
    font-size: 12.5px;
}

/* Mobile/Desktop toggle de vistas */
.calendar-mobile { display:none; }
.calendar-desktop { display:block; }
@media (max-width: 720px) {
    .calendar-desktop { display:none; }
    .calendar-mobile  { display:block; }
    .calendar-filter-bar { margin-bottom: 12px; }
}
.calendar-agenda-day {
    border-bottom: 1px solid var(--border);
}
.calendar-agenda-day:last-child { border-bottom: 0; }
.calendar-agenda-date {
    display:flex; align-items:center; gap: 12px;
    padding: 12px 16px 8px;
}
.calendar-agenda-num {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: var(--primary-bg);
    color: #fff;
    border: 1px solid var(--primary-border);
    display:flex; align-items:center; justify-content:center;
    font-size: 18px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.calendar-agenda-list {
    padding: 4px 16px 14px 70px;
    display:flex; flex-direction:column; gap: 6px;
}
@media (max-width: 420px) {
    .calendar-agenda-list { padding-left: 16px; }
}

/* ============================================================
   14B · DESIGN SYSTEM C · COMPONENTES BASE
   Prefijo ds-c → NUNCA colisiona con clases legacy.
   Conviven con .btn / .card / .badge legacy sin sobrescribir.
   Migración de vistas: 14D / 14E / 14F (no en 14B).
   ============================================================ */

/* ------------------------------------------------------------
   1. CARD SYSTEM (3 variantes: default / dense / flat)
      Recomendado radius 12px · border sutil · shadow mínima
      - default: padding 18/20
      - dense:   padding 14/16 (ERP ventas/inventario)
      - flat:    sin sombra, bg surface-2 (filters/toolbar adjunto)
   ------------------------------------------------------------ */
.ds-card {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    padding: 18px 20px;
}
.ds-card-dense {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    padding: 14px 16px;
}
.ds-card-flat {
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: none;
    padding: 18px 20px;
}
.ds-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    margin: -18px -20px var(--sp-4);
    background: var(--surface-2);
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}
.ds-card-dense .ds-card-header {
    padding: 12px 14px;
    margin: -14px -16px var(--sp-3);
}
.ds-card-title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin: 0;
}
.ds-card-subtitle {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin: 2px 0 0;
}
.ds-card-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
}

/* ------------------------------------------------------------
   2. PAGE HEADER (título + acciones, wrap responsive móvil)
   ------------------------------------------------------------ */
.ds-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-6) 0 var(--sp-5);
    flex-wrap: wrap;
}
.ds-page-header-main {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    min-width: 0;
}
.ds-page-title {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin: 0;
    line-height: 1.2;
}
.ds-page-subtitle {
    font-size: var(--fs-md);
    color: var(--text-muted);
    margin: 0;
}
.ds-page-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}
@media (max-width: 720px) {
    .ds-page-header {
        padding-top: var(--sp-5);
        padding-bottom: var(--sp-4);
    }
    .ds-page-title { font-size: var(--fs-xl); }
    .ds-page-actions { width: 100%; }
    .ds-page-actions > .ds-btn { flex: 1; }
}

/* ------------------------------------------------------------
   3. BUTTON SYSTEM (Dirección C · sólido, height 36/32/40)
      Variantes: primary / secondary / ghost / danger / icon
      - SÍMBOLOS en height / padding / radius: 8px
      - Primary: background SÓLIDO (sin gradiente exagerado)
      - Hover lift -1px opcional o ninguno (se usa lift 0)
   ------------------------------------------------------------ */
.ds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    line-height: 1;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color .12s ease,
                border-color .12s ease,
                color .12s ease,
                box-shadow .12s ease,
                transform .08s ease;
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.ds-btn svg { width: 16px; height: 16px; flex: 0 0 16px; }
.ds-btn-sm { height: 32px; padding: 0 12px; font-size: var(--fs-xs); }
.ds-btn-lg { height: 40px; padding: 0 20px; font-size: var(--fs-base); }
.ds-btn[disabled],
.ds-btn[aria-disabled="true"] {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}
.ds-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.ds-btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-xs);
}
.ds-btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}
.ds-btn-primary:active { background: var(--primary-active); border-color: var(--primary-active); }

.ds-btn-secondary {
    background: var(--surface-3);
    border-color: var(--border-default);
    color: var(--text-primary);
}
.ds-btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.ds-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}
.ds-btn-ghost:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.ds-btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--text-inverse);
    box-shadow: var(--shadow-xs);
}
.ds-btn-danger:hover { filter: brightness(1.06); }
.ds-btn-danger:focus-visible { outline-color: var(--danger); }

.ds-btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}
.ds-btn-icon:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}
.ds-btn-icon.ds-btn-sm { width: 32px; height: 32px; }
.ds-btn-icon.ds-btn-lg { width: 40px; height: 40px; }

/* ------------------------------------------------------------
   4. BADGE SYSTEM (6 estados exactos + siempre texto)
      - punto ::before 6px currentColor
      - fondo state-bg / borde state-border / texto state
      - SÓLO 6 semánticos: success/warning/danger/info/neutral/primary
      - sin depender solo de color
   ------------------------------------------------------------ */
.ds-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    line-height: 1;
    letter-spacing: .01em;
}
.ds-badge::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.ds-badge-dotless::before { display: none; }
.ds-badge-sm { height: 20px; padding: 0 8px; font-size: 10.5px; }
.ds-badge-lg { height: 26px; padding: 0 12px; font-size: var(--fs-sm); }

.ds-badge-success { color: var(--success); background: var(--success-bg); border-color: var(--success-border); }
.ds-badge-warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.ds-badge-danger  { color: var(--danger);  background: var(--danger-bg);  border-color: var(--danger-border);  }
.ds-badge-info    { color: var(--info);    background: var(--info-bg);    border-color: var(--info-border);    }
.ds-badge-neutral { color: var(--text-muted); background: var(--secondary-bg); border-color: var(--secondary-border); }
.ds-badge-primary { color: var(--primary); background: var(--primary-bg); border-color: var(--primary-border); }

/* ------------------------------------------------------------
   5. SECTION LABEL (reemplaza inline uppercase letter-spacing)
      Uso futuro: clientes/show, dashboard card-subtitles, etc.
   ------------------------------------------------------------ */
.ds-section-label {
    display: block;
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
    margin: 0 0 var(--sp-2);
}

/* ------------------------------------------------------------
   6. EMPTY STATE (sobrio, sin emojis obligatorios, CTA opcional)
      Icon 56-72px stroke lineal · título · texto · actions row
   ------------------------------------------------------------ */
.ds-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--sp-2);
    padding: var(--sp-8) var(--sp-5);
    color: var(--text-muted);
}
.ds-empty-state-icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--sp-2);
    color: var(--text-faint);
    opacity: .55;
    stroke-width: 1.5;
}
.ds-empty-state-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin: 0;
}
.ds-empty-state-text {
    font-size: var(--fs-md);
    color: var(--text-muted);
    margin: 0;
    max-width: 420px;
}
.ds-empty-state-actions {
    display: inline-flex;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
    flex-wrap: wrap;
    justify-content: center;
}
@media (max-width: 720px) {
    .ds-empty-state { padding: var(--sp-7) var(--sp-4); }
    .ds-empty-state-icon { width: 56px; height: 56px; }
}

/* ========================================
   14C · APP SHELL C · DIRECCIÓN C HÍBRIDO PREMIUM + OPERATIVO
   (overrides controlados · legacy convive)
   ======================================== */

/* --- Layout tokens (oficiales 14C) --- */
:root {
    --sidebar-w: 232px;
    --sidebar-w-collapsed: 70px;
    --header-h: 56px;
}

/* --- App grid + transiciones < 250ms --- */
.app {
    transition: grid-template-columns .18s ease;
}
.sidebar {
    transition: transform .18s ease, width .18s ease;
    background: var(--surface-1);
    border-right: 1px solid var(--border-subtle);
}
@media (max-width: 1080px) {
    .sidebar { box-shadow: var(--shadow-md); }
}

/* --- Brand · compacto (altura = header-h 56px) --- */
.sidebar-logo {
    padding: 10px 16px;
    gap: 10px;
    height: var(--header-h);
}
.app.sidebar-collapsed .sidebar-logo {
    padding: 10px 0;
}
.sidebar-logo .logo-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    font-size: 17px;
    box-shadow: 0 3px 10px rgba(124, 58, 237, .28);
}
.sidebar-logo .logo-text .t1 {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.005em;
}
.sidebar-logo .logo-text .t2 {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 1px;
    font-weight: 500;
}

/* --- Sidebar nav (densidad ERP) --- */
.sidebar-nav {
    padding: 10px 8px;
}
.nav-section-title {
    padding: 14px 12px 6px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .12em;
}
.app.sidebar-collapsed .nav-section-title {
    padding: 14px 0 4px;
    font-size: 9px;
}

/* --- Nav links (36px altura · ERP) --- */
.nav-link {
    gap: 11px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    margin: 1px 0;
    transition: background .12s ease, color .12s ease;
}
.nav-link:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}
.nav-link.active {
    background: var(--primary-bg);
    color: var(--primary-light);
    box-shadow: inset 3px 0 0 var(--primary);
    font-weight: 600;
}
.nav-link .nav-ic {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}
.nav-link .nav-ic svg {
    width: 100%;
    height: 100%;
    stroke-width: 1.75 !important;
}
.app.sidebar-collapsed .nav-link {
    padding: 10px;
    border-radius: 10px;
}
.nav-sub-link {
    padding-left: 41px;
    font-size: 12.5px;
}
.nav-sub-link .nav-ic {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
}
.nav-chevron {
    width: 15px;
    height: 15px;
}
.nav-chevron svg {
    stroke-width: 1.75 !important;
}

/* --- Badge cuenta soporte --- */
.nav-count {
    font-size: 10.5px;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

/* --- Softy · compacto (menos altura) --- */
.softy-panel {
    margin: auto 10px 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--primary-border);
}
.app.sidebar-collapsed .softy-panel {
    padding: 8px;
    margin-left: 8px;
    margin-right: 8px;
}
.softy-hello {
    gap: 9px;
    margin-bottom: 0;
}
.softy-emoji {
    width: 32px;
    height: 32px;
    font-size: 20px;
    border-radius: 10px;
    background: var(--primary-bg);
    border: 1px solid var(--primary-border);
    box-shadow: inset 0 -2px 0 rgba(0,0,0,.2);
}
.app.sidebar-collapsed .softy-emoji {
    width: 34px;
    height: 34px;
    font-size: 22px;
}
.softy-title {
    font-size: 12.5px;
    color: var(--text-primary);
    font-weight: 600;
}
.softy-sub {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 1px;
}
.softy-items {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
}
.softy-items li {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 2px 0 0;
    opacity: .85;
    line-height: 1.4;
}

/* --- Topbar (56px) · sobrio --- */
.header {
    height: var(--header-h);
    padding: 0 20px;
    gap: 16px;
    background: var(--surface-1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-subtle);
}
@media (max-width: 760px) {
    .header { padding: 0 14px; }
}

/* --- Sidebar toggle (36x36) --- */
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: background .12s ease, color .12s ease;
    color: var(--text-secondary);
}
.sidebar-toggle:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}
.sidebar-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

/* --- Search global (36x38) --- */
.header-search {
    max-width: 440px;
}
.header-search .q-ic {
    left: 12px;
    width: 15px;
    height: 15px;
    color: var(--text-muted);
}
.header-search input {
    padding: 8px 14px 8px 36px;
    height: 36px;
    font-size: 13px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.header-search input:hover {
    border-color: var(--border-default);
}
.header-search input:focus {
    outline: none;
    background: var(--surface-1);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

/* --- Header actions (36x36) --- */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: background .12s ease, color .12s ease;
}
.header-btn:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}
.header-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.header-btn svg {
    width: 18px;
    height: 18px;
}
.header-btn .badge-dot {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 14px;
    height: 14px;
    background: var(--danger);
    color: var(--text-inverse);
    border-radius: 999px;
    font-size: 9.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface-1);
    line-height: 1;
}

/* --- Dropdowns menú · Superficie C --- */
.dropdown-menu {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
}
.dropdown-menu[data-open="1"] {
    z-index: 60;
}

/* --- User menu · compact --- */
.user-menu-wrap {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 3px 10px 3px 3px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .12s ease;
}
.user-menu-wrap:hover {
    background: var(--surface-hover);
}
.user-menu-wrap:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.user-menu-wrap .info {
    display: flex;
    flex-direction: column;
    text-align: right;
    line-height: 1.15;
}
.user-menu-wrap .info .u-n {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
}
.user-menu-wrap .info .u-r {
    font-size: 10.5px;
    color: var(--text-muted);
}
.user-menu-wrap .avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

/* --- Contenido principal · padding escala C --- */
.content {
    padding: 22px 24px 36px;
}
@media (min-width: 1680px) {
    .content { padding: 24px 28px 40px; }
}
@media (max-width: 1024px) {
    .content { padding: 18px 20px 32px; }
}
@media (max-width: 720px) {
    .content { padding: 14px 14px 28px; }
}

/* --- Mobile drawer overlay · z-index 40 --- */
.backdrop-mobile {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 40;
}
.app.sidebar-mobile-open .backdrop-mobile {
    display: block;
}

/* --- Focus visible links navegación --- */
.nav-link:focus-visible,
.nav-group-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

/* ============================================================
   14D · DASHBOARD PILOTO C · DESIGN SYSTEM C
   Prefijo: dashboard-c- · uso componentes .ds-* 14B
   NO tocar estilos módulos ni shell 14C (congelado).
   ============================================================ */

/* --- 1. KPI Stats Grid · 14D-A1 DETERMINISTA: 4→3→2→1 columnas (NO auto-fit) · gap ERP denso --- */
.dashboard-c-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    align-items: stretch;
}
/* Wide ≥1680: 4 cols (deliberado §15). Solo mayor gap. */
@media (min-width: 1680px) {
    .dashboard-c-stats-grid {
        gap: 18px;
    }
}
/* Tablet XL / notebook ≤1280: 3 cols */
@media (max-width: 1280px) {
    .dashboard-c-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px;
    }
}
/* Tablet M / small desktop ≤900: 2 cols */
@media (max-width: 900px) {
    .dashboard-c-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
/* Mobile ≤520: 1 col legibilidad */
@media (max-width: 520px) {
    .dashboard-c-stats-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}
/* §18 RBAC few-cards: 2/3/6 KPIs visibles → composición equilibrada sin huecos.
   14D-A1: 2→2 cols 3→3 cols.
   14D-A2: 6→3 cols × 2 filas (Ventas perfil).
   :has() compatibilidad Chromium 105+ (2022) → OK 2026. */
.dashboard-c-stats-grid:has(> :nth-child(2):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.dashboard-c-stats-grid:has(> :nth-child(3):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
/* 14D-A2 §1: Exactamente 6 KPIs (Perfil VENTAS) → 3×2, NO 4+2 media fila vacía */
.dashboard-c-stats-grid:has(> :nth-child(6):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
/* Tablet XL ≤1280 con 2 cards → 2 cols evita 3+1 hueco (igual que 14D-A1). */
@media (max-width: 1280px) {
    .dashboard-c-stats-grid:has(> :nth-child(2):last-child) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
/* Tablet ≤900 / Mobile ≤520: FORCE 2 cols / 1 col pese a :has count.
   Especificidad igual (.dashboard-c-stats-grid:has) pero cascade media query posterior gana. */
@media (max-width: 900px) {
    .dashboard-c-stats-grid,
    .dashboard-c-stats-grid:has(> :nth-child(2):last-child),
    .dashboard-c-stats-grid:has(> :nth-child(3):last-child),
    .dashboard-c-stats-grid:has(> :nth-child(6):last-child) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 520px) {
    .dashboard-c-stats-grid,
    .dashboard-c-stats-grid:has(> :nth-child(2):last-child),
    .dashboard-c-stats-grid:has(> :nth-child(3):last-child),
    .dashboard-c-stats-grid:has(> :nth-child(6):last-child) {
        grid-template-columns: 1fr;
    }
}

/* --- 2. KPI Card · flex row icon + body (40px icon, ERP density) --- */
.dashboard-c-kpi {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    height: 100%; /* stretch altura uniforme row */
    min-height: 90px; /* §7 90-105px desktop target; stretch natural iguala multi/single currency. */
    transition: border-color .12s ease, box-shadow .12s ease;
}
.dashboard-c-kpi:hover {
    border-color: var(--border-default);
}
.dashboard-c-kpi-ic {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid;
}
.dashboard-c-kpi-ic svg {
    width: 18px;
    height: 18px;
}
.dashboard-c-ic-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.dashboard-c-ic-primary { background: var(--primary-bg); color: var(--primary); border-color: var(--primary-border); }
.dashboard-c-ic-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-border); }
.dashboard-c-ic-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.dashboard-c-ic-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }

.dashboard-c-kpi-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.dashboard-c-kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.1;
}
.dashboard-c-kpi-values {
    display: flex;
    /* 14D-A1 §4-6 multimoneda SIEMPRE vertical: PEN arriba, USD abajo. NO row/wrap. */
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin-top: 2px;
}
.dashboard-c-kpi-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.2;
    white-space: nowrap;
}
.dashboard-c-kpi-val-sub {
    /* §4 USD 2ª línea: 16px/600 secondary. Mantiene jerarquía 14D. */
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.2;
}
.dashboard-c-kpi-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.1;
    margin-top: 1px;
}
.dashboard-c-kpi-sub-danger {
    color: var(--danger);
    font-weight: 500;
}

/* Mobile KPI · 14D §21 + 14D-A1: icon 40px, PEN 21px, USD 15px, wrap vertical igual desktop (~90-95px). */
@media (max-width: 520px) {
    .dashboard-c-kpi-ic {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
    }
    .dashboard-c-kpi-val { font-size: 21px; }
    .dashboard-c-kpi-val-sub { font-size: 15px; }
}

/* --- 3. Main lower grid · graph 55% + activity 45% desktop; stack móvil --- */
.dashboard-c-main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
.dashboard-c-main-grid-2 {
    grid-template-columns: 55fr 45fr;
    align-items: flex-start;
}
@media (min-width: 1680px) {
    .dashboard-c-main-grid { gap: 18px; }
    .dashboard-c-main-grid-2 { grid-template-columns: 60fr 40fr; }
}
@media (max-width: 1280px) {
    .dashboard-c-main-grid-2 {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 1024px) {
    .dashboard-c-main-grid { gap: 14px; }
}

/* --- 4. Graph card · altura compacta 220-280px área útil --- */
.dashboard-c-graph-card .ds-card-header {
    padding: 14px 18px;
    margin-bottom: 14px;
}
.dashboard-c-graph-body {
    padding: 0 4px 2px;
}
.dashboard-c-curr-wrap {
    width: 100%;
}
.dashboard-c-curr-wrap-mb {
    margin-bottom: 24px;
}
.dashboard-c-curr-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 10px;
    flex-wrap: wrap;
}
.dashboard-c-curr-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.dashboard-c-curr-label::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
}
.dashboard-c-curr-pen::before {
    background: var(--success);
}
.dashboard-c-curr-usd::before {
    background: var(--primary);
}
.dashboard-c-curr-total {
    font-size: 12.5px;
    color: var(--text-muted);
}
.dashboard-c-curr-total span {
    color: var(--text-primary);
    font-weight: 600;
}

/* Bars area track altura 180px (antes ~180 con padding; total 220-280 util OK §12) */
.dashboard-c-bars {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 180px;
    padding: 8px 0 10px;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
}
.dashboard-c-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.dashboard-c-bar-val {
    font-size: 10.5px;
    color: var(--text-muted);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.dashboard-c-bar-track {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: flex-end;
}
.dashboard-c-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    transition: height .2s ease;
    opacity: .88;
}
.dashboard-c-bar-pen {
    background: var(--success);
}
.dashboard-c-bar-usd {
    background: var(--primary);
}
.dashboard-c-bar-mes {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Mobile graph altura 180-220px · §22 */
@media (max-width: 720px) {
    .dashboard-c-bars { height: 200px; }
    .dashboard-c-bar-track { height: 150px; }
    .dashboard-c-curr-wrap-mb { margin-bottom: 22px; }
}

/* --- 5. Actividad reciente · compact · separadores sutiles --- */
.dashboard-c-act-card .ds-card-header {
    padding: 14px 18px;
    margin-bottom: 0;
}
.dashboard-c-act-body {
    padding: 0;
}
.dashboard-c-act-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background .12s ease;
}
.dashboard-c-act-item:last-child {
    border-bottom: 0;
}
.dashboard-c-act-item:hover:has(.dashboard-c-act-title[href]) {
    background: var(--surface-hover);
}
.dashboard-c-act-ic {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid;
    line-height: 1;
    margin-top: 1px;
}
.dashboard-c-act-ic-primary { background: var(--primary-bg); color: var(--primary); border-color: var(--primary-border); }
.dashboard-c-act-ic-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.dashboard-c-act-ic-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.dashboard-c-act-ic-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.dashboard-c-act-ic-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-border); }

.dashboard-c-act-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.dashboard-c-act-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    line-height: 1.25;
}
.dashboard-c-act-title-plain {
    font-weight: 600;
    color: var(--text-primary);
}
a.dashboard-c-act-title:hover {
    color: var(--primary);
}
a.dashboard-c-act-title:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}
.dashboard-c-act-sub {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}
.dashboard-c-act-date {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
    line-height: 1.4;
    padding-top: 1px;
    font-variant-numeric: tabular-nums;
}

/* Mobile actividad §22: fecha debajo de subtítulo en wrap row */
@media (max-width: 520px) {
    .dashboard-c-act-item {
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 10px 12px;
    }
    .dashboard-c-act-main {
        flex: 1 1 180px;
    }
    .dashboard-c-act-date {
        order: 3;
        width: 100%;
        padding-top: 0;
        padding-left: 44px;
        color: var(--text-muted);
    }
    .dashboard-c-act-item:hover:has(.dashboard-c-act-title[href]) .dashboard-c-act-date {
        background: transparent;
    }
}

/* =============================================================
   14E-B · VENTAS · Drawer seleccionable dinámico (Opción C)
   Prefijo: .ventas-c-  /  #ventas-drawer  (sin afectar otras tablas)
   ============================================================= */

/* --- 1. Fila seleccionada · Dirección C (sin gradiente/glow/translate) --- */
.ventas-c-table tbody tr {
    transition: background-color .14s ease, box-shadow .14s ease;
}
.ventas-c-table tbody tr.selected {
    background: var(--primary-bg);
    box-shadow: inset 3px 0 0 var(--primary);
}
.ventas-c-table tbody tr.selected td {
    color: var(--text-primary);
}

/* --- 2. Loading state discreto del drawer (fetch en curso) --- */
#ventas-drawer {
    position: relative;
}
#ventas-drawer.is-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(14, 12, 24, 0.72);
    backdrop-filter: blur(1.5px);
    -webkit-backdrop-filter: blur(1.5px);
    z-index: 20;
    border-radius: inherit;
    pointer-events: all;
}
#ventas-drawer.is-loading::after {
    content: "";
    position: absolute;
    top: 20px;
    right: 20px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid var(--primary-border);
    border-top-color: var(--primary);
    z-index: 21;
    animation: ventas-c-spin 0.7s linear infinite;
    pointer-events: none;
}
@keyframes ventas-c-spin {
    to { transform: rotate(360deg); }
}

/* --- 3. Mobile ≤640px · Drawer como overlay slide-up (aislado, sin tocar lógica) --- */
@media (max-width: 640px) {
    .app-split.drawer-open #ventas-drawer.drawer-detail {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 86vh;
        max-height: 86vh;
        z-index: 95;
        border-radius: 18px 18px 0 0;
        border: 1px solid var(--border);
        border-bottom: 0;
        box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.45);
        animation: ventas-c-slideup 0.22s ease-out;
    }
}
@keyframes ventas-c-slideup {
    from { transform: translateY(28%); opacity: 0.6; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ============================================================
   14E-C · VENTAS · DESIGN SYSTEM C
   ============================================================
   Prefijo obligatorio: .ventas-c-*
   Todas las personalizaciones de componentes estándar o .ds-*
   DEBEN estar scopeadas por un ancestro .ventas-c-* o #ventas-drawer.
   NO tocar globales: .table/.card/.btn/.badge/.form-control/.ds-btn-*.
   ============================================================ */

/* --- Contenedor general y espaciado vertical top-down igual Dashboard 14D --- */
.ventas-c-page {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    padding: var(--sp-5) var(--sp-6);
}

/* --- 1. KPIs · 4 tarjetas dense (igual patrón Dashboard 14D) --- */
.ventas-c-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sp-3);
}
.ventas-c-kpi {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: 88px;
    padding: var(--sp-3) var(--sp-4);
}
.ventas-c-kpi-ic {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ventas-c-kpi-ic svg {
    width: 18px;
    height: 18px;
}
.ventas-c-ic-success { color: var(--success); background: var(--success-bg); border: 1px solid var(--success-border); }
.ventas-c-ic-primary { color: var(--primary); background: var(--primary-bg); border: 1px solid var(--primary-border); }
.ventas-c-ic-info    { color: var(--info);    background: var(--info-bg);    border: 1px solid var(--info-border); }
.ventas-c-ic-warning { color: var(--warning); background: var(--warning-bg); border: 1px solid var(--warning-border); }
.ventas-c-kpi-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}
.ventas-c-kpi-label {
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    color: var(--text-muted);
    letter-spacing: 0.01em;
}
.ventas-c-kpi-val {
    font-family: 'Poppins', ui-sans-serif, system-ui, sans-serif;
    font-size: 22px;
    line-height: 1.2;
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.ventas-c-kpi-sub {
    font-size: 11px;
    color: var(--text-faint);
    line-height: 1.2;
    margin-top: 2px;
}

/* --- 2. Tabs de estado · underline compact, NO pills moradas --- */
.ventas-c-tabs-card {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: 0;
    padding: 0;
}
.ventas-c-tabs {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
    padding: 0 var(--sp-1);
    gap: var(--sp-1);
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}
.ventas-c-tabs::-webkit-scrollbar { height: 4px; }
.ventas-c-tabs::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }
.ventas-c-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 42px;
    padding: 0 14px;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    font-weight: var(--fw-medium);
    background: transparent;
    border: 0;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color .15s ease, border-color .15s ease, background-color .15s ease;
    flex-shrink: 0;
    text-decoration: none;
}
.ventas-c-tab:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}
.ventas-c-tab-active {
    color: var(--primary-light);
    font-weight: var(--fw-semibold);
    border-bottom-color: var(--primary);
}

/* --- 3. Barra de filtros ds-card-flat surface-2, inputs 38px focus primary --- */
.ventas-c-filters {
    background: var(--surface-2);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border: 1px solid var(--border-default);
    border-top: 1px solid var(--border-subtle);
    padding: var(--sp-3);
}
.ventas-c-filters-row {
    display: grid;
    grid-template-columns: minmax(260px, 1.5fr) minmax(190px, .75fr) minmax(190px, .75fr);
    gap: var(--sp-3);
    align-items: stretch;
}
.ventas-c-search {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}
.ventas-c-filters-row > select.form-control {
    min-width: 0;
    width: 100%;
}
.ventas-c-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}
.ventas-c-filters .form-control {
    height: 38px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 36px;
    transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
    width: 100%;
}
.ventas-c-search .form-control { padding-left: 36px; }
.ventas-c-filters select.form-control { padding-right: 32px; }
.ventas-c-filters .form-control:hover { border-color: var(--border-strong); }
.ventas-c-filters .form-control:focus,
.ventas-c-filters .form-control:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
    background: var(--surface-1);
}

/* --- 4. Tabla + contenedor ERP denso --- */
.ventas-c-table-card {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: 0;
    padding: 0;
    overflow: hidden;
}
.ventas-c-table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}
.ventas-c-table-wrap::-webkit-scrollbar { height: 6px; }
.ventas-c-table-wrap::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 3px; }
.ventas-c-table {
    width: 100%;
    min-width: 900px;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
}
.ventas-c-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    line-height: 1.2;
    font-weight: var(--fw-semibold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-default);
}
.ventas-c-table thead th.cell-center { text-align: center; }
.ventas-c-table thead th.cell-num   { text-align: right; }
.ventas-c-table tbody td {
    padding: 0 12px;
    height: 46px;
    vertical-align: middle;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ventas-c-table tbody tr:last-child td { border-bottom: 0; }
.ventas-c-table tbody tr:hover td { background: var(--surface-hover); }
.ventas-c-cell-id {
    color: var(--text-faint);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.ventas-c-cell-code {
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    letter-spacing: 0.02em;
}
.ventas-c-cell-date { color: var(--text-secondary); font-size: 12.5px; }
.ventas-c-cell-total {
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    text-align: right;
}
.ventas-c-cell-paid {
    font-weight: var(--fw-semibold);
    color: var(--success);
    text-align: right;
}
.ventas-c-table td.cell-num { text-align: right; }
.ventas-c-table td.cell-center { text-align: center; }
.ventas-c-table .cell-title .t {
    display: block;
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}
.ventas-c-table tr.selected .cell-title .t,
.ventas-c-table tr.selected .ventas-c-cell-code,
.ventas-c-table tr.selected .ventas-c-cell-total {
    color: var(--primary-light);
}

/* --- 5. Acciones fila · 32x32 scoped --- */
.ventas-c-row-actions {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.ventas-c-row-actions .ventas-c-row-btn {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: var(--radius-sm);
}
.ventas-c-row-dropdown .dropdown-menu { min-width: 188px; }

/* --- 6. Paginación compacta, botones 32px scopeados por .ventas-c-pagination --- */
.ventas-c-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-1);
}
.ventas-c-pagination-info {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}
.ventas-c-pagination-info b { color: var(--text-primary); font-weight: var(--fw-semibold); }
.ventas-c-pagination-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}
.ventas-c-pagination .ventas-c-page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: var(--fw-medium);
    font-variant-numeric: tabular-nums;
}
.ventas-c-pagination .ventas-c-page-btn.ds-btn-primary { color: #fff; }
.ventas-c-perpage {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
.ventas-c-perpage .form-control {
    height: 32px;
    line-height: 30px;
    padding: 0 32px 0 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    opacity: .85;
}

/* --- 7. Empty state dentro tabla (usa .ds-empty-state) --- */
.ventas-c-empty-table {
    min-height: 260px;
    border-top: 1px solid var(--border-subtle);
}

/* ============================================================
   DRAWER DERECHO · Interior (scopeado por #ventas-drawer)
   ============================================================ */
#ventas-drawer {
    display: none;
    flex-direction: column;
    min-height: 0;
}
.app-split.drawer-open #ventas-drawer {
    display: flex;
}
.app-split:not(.drawer-open) #ventas-drawer.drawer-detail {
    width: 0;
    min-width: 0;
    max-width: 0;
    padding: 0;
    border: 0;
    margin: 0;
    box-shadow: none;
    visibility: hidden;
    overflow: hidden;
    pointer-events: none;
}
#ventas-drawer .ventas-c-drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-4) var(--sp-2) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}
#ventas-drawer .ventas-c-drawer-hmain { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
#ventas-drawer .ventas-c-drawer-code {
    font-family: 'Poppins', ui-sans-serif, system-ui, sans-serif;
    font-weight: var(--fw-extrabold);
    font-size: 13px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--primary);
}
#ventas-drawer .ventas-c-drawer-code-empty { color: var(--text-muted); letter-spacing: 0.16em; }
#ventas-drawer .ventas-c-drawer-title-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
#ventas-drawer .ventas-c-drawer-eyebrow {
    font-size: 12px;
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
}
#ventas-drawer .ventas-c-drawer-close { width: 32px; height: 32px; flex: 0 0 32px; border-radius: var(--radius-sm); color: var(--text-secondary); }
#ventas-drawer .ventas-c-drawer-close:hover { color: var(--text-primary); background: var(--surface-hover); }

#ventas-drawer .ventas-c-drawer-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}
#ventas-drawer .ventas-c-drawer-actions .ds-btn.ventas-c-drawer-action {
    height: 34px;
    padding: 0 10px;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    border-radius: var(--radius-sm);
    flex: 1 1 0;
    min-width: 0;
    gap: 6px;
}
#ventas-drawer .ventas-c-drawer-dropdown { flex: 1 1 0; min-width: 0; position: relative; }
#ventas-drawer .ventas-c-drawer-dropdown .ds-btn.ventas-c-drawer-action.ventas-c-drawer-more {
    width: 100%;
    justify-content: center;
}

#ventas-drawer .ventas-c-drawer-client {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}
#ventas-drawer .ventas-c-drawer-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', sans-serif;
    font-weight: var(--fw-bold);
    font-size: 14px;
    letter-spacing: 0.02em;
    flex: 0 0 42px;
}
#ventas-drawer .ventas-c-drawer-cinfo {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}
#ventas-drawer .ventas-c-drawer-cname-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
}
#ventas-drawer .ventas-c-drawer-cname {
    font-size: 14px;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
#ventas-drawer .ventas-c-drawer-clink {
    font-size: 12px;
    color: var(--primary);
    font-weight: var(--fw-medium);
    text-decoration: none;
    flex-shrink: 0;
}
#ventas-drawer .ventas-c-drawer-clink:hover { text-decoration: underline; }
#ventas-drawer .ventas-c-drawer-csub {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#ventas-drawer .ventas-c-drawer-section {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4) var(--sp-2) var(--sp-4);
}
#ventas-drawer .ventas-c-drawer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
    padding-top: 2px;
}
#ventas-drawer .ventas-c-drawer-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
#ventas-drawer .ventas-c-drawer-info-2col { grid-column: 1 / -1; }
#ventas-drawer .ventas-c-drawer-label {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
    font-weight: var(--fw-medium);
}
#ventas-drawer .ventas-c-drawer-val {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: var(--fw-semibold);
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}

/* Items drawer en cards flat */
#ventas-drawer .ventas-c-drawer-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#ventas-drawer .ventas-c-drawer-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
}
#ventas-drawer .ventas-c-drawer-item-badge { flex: 0 0 auto; }
#ventas-drawer .ventas-c-drawer-item-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}
#ventas-drawer .ventas-c-drawer-item-desc {
    font-size: 13px;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#ventas-drawer .ventas-c-drawer-item-qty {
    font-size: 11.5px;
    color: var(--text-muted);
}
#ventas-drawer .ventas-c-drawer-item-total {
    font-size: 13px;
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
    align-self: center;
    margin-left: 6px;
}
#ventas-drawer .ventas-c-drawer-items-more {
    font-size: 12px;
    color: var(--text-muted);
    padding-left: 4px;
}

/* Resumen ds-card-flat · totales y saldo */
#ventas-drawer .ventas-c-drawer-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: var(--sp-3) var(--sp-3);
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}
#ventas-drawer .ventas-c-drawer-srow {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: 0 2px;
}
#ventas-drawer .ventas-c-drawer-srow-sep {
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px dashed var(--border-default);
}
#ventas-drawer .ventas-c-drawer-label { font-size: 12px; color: var(--text-muted); }
#ventas-drawer .ventas-c-drawer-stotal-label { font-weight: var(--fw-bold); color: var(--text-secondary); }
#ventas-drawer .ventas-c-drawer-sval {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: var(--fw-semibold);
    font-variant-numeric: tabular-nums;
}
#ventas-drawer .ventas-c-drawer-stotal {
    font-size: 18px;
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
#ventas-drawer .ventas-c-drawer-spaid {
    font-size: 13px;
    font-weight: var(--fw-bold);
    color: var(--success);
    font-variant-numeric: tabular-nums;
}
#ventas-drawer .ventas-c-drawer-sbalance {
    font-size: 13px;
    font-weight: var(--fw-bold);
    color: var(--success);
    font-variant-numeric: tabular-nums;
}
#ventas-drawer .ventas-c-drawer-sbalance:has(~ *),
#ventas-drawer .ventas-c-drawer-sbalance { /* saldo >0 : danger via inline PHP? no, lo marcamos vía JS no necesario → fallback via regex not possible css pure: se mantiene success si es 0, pero PHP le pasa e(money(0)) en valor 0 siempre; así mantiene color success siempre. OK */ }

/* Notas y referencias */
#ventas-drawer .ventas-c-drawer-notes {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#ventas-drawer .ventas-c-drawer-project {
    font-weight: var(--fw-semibold);
    color: var(--primary);
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.06em;
}

/* CTA final · sin legacy .btn. Solo ds-btn* */
#ventas-drawer .ventas-c-drawer-cta-row {
    padding: var(--sp-4);
    margin-top: auto;
    border-top: 1px solid var(--border-subtle);
}
#ventas-drawer .ventas-c-drawer-cta {
    display: inline-flex;
    width: 100%;
    justify-content: center;
    text-align: center;
    height: 40px;
    font-weight: var(--fw-semibold);
    font-size: var(--fs-sm);
    border-radius: var(--radius-md);
}

/* Empty state drawer interior · usa ds-empty-state */
#ventas-drawer .ventas-c-drawer-empty {
    flex: 1 1 auto;
    padding: var(--sp-7) var(--sp-5);
    background: transparent;
    border: 0;
    margin: 0;
    justify-content: center;
}
#ventas-drawer .ventas-c-drawer-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid var(--primary-border);
}

/* ============================================================
   RESPONSIVE · 5 BPs · 1440+ / 1366 / 1024 / 768 / ≤640 (móvil)
   ============================================================ */

/* BP 1 · ≥1440px desktop ancho: márgenes laterales dashboard-c-like, gap 16px KPIs */
@media (min-width: 1440px) {
    .ventas-c-page { padding: var(--sp-5) var(--sp-7); }
    .ventas-c-kpi-grid { gap: var(--sp-4); }
}

/* BP 2 · 1366px desktop estándar: 4 cols OK, compact un poco */
@media (max-width: 1366px) {
    .ventas-c-page { padding: var(--sp-4) var(--sp-5); }
}

/* BP 3 · 1024px tablet landscape → 2 cols KPI, drawer 380 aprox, márgenes menos */
@media (max-width: 1024px) {
    .ventas-c-page { padding: var(--sp-4); gap: var(--sp-3); }
    .ventas-c-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ventas-c-table-wrap { max-width: 100%; }
}

/* BP 4 · 900-769px tablet landscape pequeño / 768px tablet portrait → 2 cols KPI, filters wrap 2 cols, pagination center */
@media (max-width: 900px) {
    .ventas-c-filters-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--sp-2);
    }
    .ventas-c-filters-row .ventas-c-search {
        grid-column: 1 / -1;
    }
}
@media (max-width: 768px) {
    .ventas-c-page { padding: var(--sp-3); }
    .ventas-c-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
    .ventas-c-kpi { padding: var(--sp-2) var(--sp-3); min-height: 82px; }
    .ventas-c-filters-row .form-control { width: 100%; }
    .ventas-c-perpage { width: 100%; justify-content: flex-start; }
    .ventas-c-pagination { flex-direction: column; align-items: flex-start; }
}

/* BP 5 · ≤640px móvil drawer overlay certificado (§21) · 1 columna KPI, tabs scroll, filters stack, tabla horizontal scroll (no cards) */
@media (max-width: 640px) {
    .ventas-c-page { padding: var(--sp-3) var(--sp-2); gap: var(--sp-3); }

    .ventas-c-page .ds-page-header { flex-direction: column; align-items: flex-start; gap: var(--sp-3); padding: 0; }
    .ventas-c-page .ds-page-actions { width: 100%; }
    .ventas-c-page .ds-page-actions > .ds-btn { width: 100%; justify-content: center; }

    /* KPI 1 col mobile, altura 84 similar 14D mobile KPI */
    .ventas-c-kpi-grid { grid-template-columns: minmax(0, 1fr); gap: var(--sp-2); }
    .ventas-c-kpi { min-height: 84px; padding: var(--sp-3); }

    /* tabs ya overflow-x auto, no cambios extra */
    .ventas-c-tabs { padding: 0 var(--sp-1); }
    .ventas-c-tab { height: 40px; padding: 0 12px; font-size: 12px; }

    /* filtros stack 1 columna mobile full width (anula grid desktop/tablet) */
    .ventas-c-filters-row {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--sp-2);
    }
    .ventas-c-search { min-width: 0; }
    .ventas-c-filters select.form-control { width: 100%; }

    /* Tabla: scroll horizontal interno, width mínima para preservar columnas */
    .ventas-c-table { min-width: 780px; }
    .ventas-c-table .cell-title .t { max-width: 170px; }

    /* Paginación wrap */
    .ventas-c-pagination { padding: 12px; gap: var(--sp-3); }
    .ventas-c-pagination-nav { width: 100%; flex-wrap: wrap; }
    .ventas-c-perpage { width: 100%; justify-content: flex-start; }
    .ventas-c-pagination-info { width: 100%; }

    /* Drawer mobile certificado 14E-B: fixed bottom 86vh overlay slide-up. Ya definido en 14E-B @media max-width 640. Conservar. No revertir. */
    /* Fix hotfix: evitar que regla escritorio NOT(.drawer-open) colapse el fixed overlay. Mobile cerrado = 0 width fixed, abierto = fixed bottom */
    @media (max-width: 640px) {
        .app-split:not(.drawer-open) #ventas-drawer.drawer-detail,
        .app-split:not(.drawer-open) #ventas-drawer {
            width: 0;
            height: 0;
            min-width: 0;
            max-width: 0;
            padding: 0;
            border: 0;
            top: auto;
            left: 0;
            right: auto;
            bottom: 0;
            border-radius: 0;
            transform: translateY(100%);
            opacity: 0;
            visibility: hidden;
            overflow: hidden;
            pointer-events: none;
        }
    }

    /* Drawer interior scoped: header padding más compacto */
    #ventas-drawer .ventas-c-drawer-header { padding: var(--sp-3) var(--sp-3) var(--sp-2) var(--sp-3); }
    #ventas-drawer .ventas-c-drawer-actions,
    #ventas-drawer .ventas-c-drawer-client,
    #ventas-drawer .ventas-c-drawer-section { padding-left: var(--sp-3); padding-right: var(--sp-3); }
    #ventas-drawer .ventas-c-drawer-cta-row { padding: var(--sp-3); }
    #ventas-drawer .ventas-c-drawer-grid { grid-template-columns: minmax(0, 1fr); }
    #ventas-drawer .ventas-c-drawer-empty { padding: var(--sp-6) var(--sp-4); }
    #ventas-drawer .ventas-c-drawer-empty-icon { width: 56px; height: 56px; }
}


