@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ============ VARIABLES ============ */
:root {
    --bg: #05070a;
    --sidebar-bg: rgba(8, 12, 20, 0.97);
    --panel-bg: rgba(16, 22, 35, 0.7);
    --panel-border: rgba(255, 255, 255, 0.07);
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.25);
    --amber: #f59e0b;
    --orange: #f97316;
    --red: #ef4444;
    --blue: #3b82f6;
    --green: #10b981;
    --purple: #8b5cf6;
    --text-1: #f1f5f9;
    --text-2: #94a3b8;
    --text-3: #475569;
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 80px;
    --header-h: 75px;
    --blur: blur(14px);
    --ease: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Dynamic Scaling Variables */
    --kpi-icon-size: 42px;
    --btn-icon-size: 18px;
    --modal-default-w: 800px;
}

/* Fluid Resizing Support */
@media (max-width: 1400px) {
    :root { --sidebar-w: 220px; --kpi-icon-size: 38px; }
    .panel-ops { flex: 1 1 100% !important; }
}

/* ============ SPLASH SCREEN ============ */
.splash-screen {
    position: fixed; inset: 0;
    background: #05070a;
    z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
}
.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}
.splash-content {
    display: flex; flex-direction: column; align-items: center; gap: 2rem;
    animation: splashPulse 2s infinite ease-in-out;
}
.splash-logo {
    position: relative; width: 100px; height: 100px;
}
.splash-logo img {
    width: 100%; height: 100%; object-fit: contain;
    z-index: 2; position: relative;
}
.logo-glow {
    position: absolute; inset: -20px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    opacity: 0.3; filter: blur(15px); z-index: 1;
    animation: glowRotate 4s infinite linear;
}
.splash-text { text-align: center; }
.splash-text h2 {
    font-size: 2rem; font-weight: 800; letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 0%, var(--text-2) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}
.splash-text p { font-size: 0.9rem; color: var(--text-2); letter-spacing: 1px; text-transform: uppercase; }

.splash-loader-bar {
    width: 200px; height: 3px; background: rgba(255,255,255,0.05);
    border-radius: 99px; overflow: hidden;
}
.loader-progress {
    height: 100%; width: 0%; background: var(--accent);
    box-shadow: 0 0 15px var(--accent);
    animation: progressLoad 2.5s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes splashPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.02); opacity: 0.9; }
}
@keyframes glowRotate {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.2); }
    100% { transform: rotate(360deg) scale(1); }
}
@keyframes progressLoad {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Animaciones de Entrada App */
.app-wrap {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.app-wrap.loaded {
    opacity: 1;
    transform: translateY(0);
}


@media (max-width: 1100px) {
    .panel-ops, .panel-cobranza, .panel-stock, .panel-tasks { 
        flex: 1 1 100% !important; 
        width: 100% !important; 
        min-height: auto !important;
    }
    .kpi-row { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important; }
}

/* ============ RESET ============ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text-1); }

 
/* ============================================================
   APP WRAPPER
   ============================================================ */
.app-wrap  { display: flex; width: 100%; height: 100vh; }
.app-hidden { display: none !important; }
.hidden    { display: none !important; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--panel-border);
    display: flex; flex-direction: column;
    padding: 1.4rem 1rem; height: 100vh;
    backdrop-filter: var(--blur);
    /* Al expandir: ancho sin delay. Al colapsar: delay para esperar al texto. */
    transition: width 0.35s cubic-bezier(0.65, 0, 0.35, 1) 0s, padding 0.35s ease 0s;
    position: relative;
    z-index: 100;
}
.sidebar.collapsed {
    width: 72px;
    padding: 1.4rem 0.5rem;
    /* Al colapsar: delay para que el texto se vaya primero */
    transition: width 0.35s cubic-bezier(0.65, 0, 0.35, 1) 0.1s, padding 0.35s ease 0.1s;
}
#toggle-ico { transition: transform 0.5s cubic-bezier(0.65, 0, 0.35, 1); }
.collapsed #toggle-ico { transform: rotate(180deg); }
.logo {
    display: flex; align-items: center; gap: 0.75rem;
    font-size: 1.2rem; font-weight: 700; color: var(--accent);
    padding: 0 0.5rem; margin-bottom: 1.75rem; letter-spacing: -0.3px;
    overflow: hidden;
    white-space: nowrap;
}
.collapsed .logo img,
.collapsed .logo-text,
.collapsed .nav-text,
.collapsed .btn-text,
.collapsed .sb-user-info {
    opacity: 0;
    max-width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    pointer-events: none;
    /* Al colapsar: se va rápido sin delay */
    transition: opacity 0.15s ease 0s, max-width 0.25s ease 0s;
}

.logo img, .logo-text, .nav-text, .btn-text, .sb-user-info {
    opacity: 1;
    max-width: 210px;
    display: inline-block;
    vertical-align: middle;
    /* Al expandir: esperamos a que el ancho se abra (0.3s delay) */
    transition: opacity 0.2s ease 0.3s, max-width 0s linear 0s;
}

.collapsed .logo {
    padding: 0;
    justify-content: center;
    gap: 0;
}
.collapsed .nav-item {
    padding: 0.72rem;
    justify-content: center;
    gap: 0;
}
.collapsed .nav-item svg {
    margin: 0;
}
.collapsed .sb-user {
    justify-content: center;
    gap: 0;
}
.collapsed .btn-logout {
    padding: 0.6rem;
    justify-content: center;
    gap: 0;
}
.nav-links { list-style: none; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.72rem 0.875rem; border-radius: 10px;
    cursor: pointer; color: var(--text-2);
    font-weight: 500; font-size: 0.875rem;
    transition: var(--ease); user-select: none;
    white-space: nowrap;
    overflow: hidden;
}
.collapsed .nav-item {
    padding: 0.72rem;
    justify-content: center;
}
.collapsed .nav-item svg {
    margin: 0;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-1); }
.nav-item.active { background: var(--accent); color: #fff; box-shadow: 0 4px 18px var(--accent-glow); }

/* Sidebar footer */
.sidebar-footer { padding-top: 1rem; border-top: 1px solid var(--panel-border); display: flex; flex-direction: column; gap: 0.6rem; }
.sb-user { display: flex; align-items: center; gap: 0.75rem; padding: 0.25rem; overflow: hidden; }
.collapsed .sb-user { justify-content: center; padding: 0; }
.sb-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.875rem; flex-shrink: 0; letter-spacing: 0;
}
.sb-user-info { display: flex; flex-direction: column; transition: var(--ease); }
.collapsed .sb-user-info { display: none; }
.sb-name { font-size: 0.85rem; font-weight: 600; }
.sb-role-text { font-size: 0.72rem; color: var(--text-2); }

.btn-logout {
    display: flex; align-items: center; gap: 0.5rem;
    width: 100%; background: rgba(239,68,68,0.07);
    color: var(--red); border: 1px solid rgba(239,68,68,0.15);
    border-radius: 9px; padding: 0.6rem 0.875rem;
    font-size: 0.8rem; font-weight: 500; cursor: pointer;
    transition: var(--ease); font-family: 'Inter', sans-serif;
    overflow: hidden; white-space: nowrap;
}
.collapsed .btn-logout {
    padding: 0.6rem;
    justify-content: center;
}
.collapsed .btn-logout svg {
    margin: 0;
}
.btn-logout:hover { background: rgba(239,68,68,0.15); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    flex: 1; overflow-y: auto;
    padding: 1.75rem 2rem;
    background: radial-gradient(ellipse at 65% -15%, rgba(16,185,129,0.07) 0%, transparent 55%);
}

.header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.75rem;
}
.header h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.4px; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.current-date {
    font-size: 0.78rem; color: var(--text-2);
    background: var(--panel-bg); border: 1px solid var(--panel-border);
    padding: 0.35rem 0.85rem; border-radius: 8px;
}

/* Role badge */
.role-badge {
    font-size: 0.7rem; font-weight: 700;
    padding: 0.32rem 0.8rem; border-radius: 99px;
    letter-spacing: 0.06em; text-transform: uppercase;
}
.rb-admin    { background: rgba(16,185,129,0.15); color: var(--accent); border: 1px solid rgba(16,185,129,0.3); }
.rb-ventas   { background: rgba(59,130,246,0.15);  color: var(--blue);   border: 1px solid rgba(59,130,246,0.3); }
.rb-cobranza { background: rgba(245,158,11,0.15);  color: var(--amber);  border: 1px solid rgba(245,158,11,0.3); }

/* ============================================================
   VIEWS
   ============================================================ */
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ============================================================
   KPI ROW
   ============================================================ */
.kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
/* KPI Icons Responsive Scaling */
.kpi-icon {
    width: 42px; 
    height: 42px; 
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: var(--ease);
    margin-bottom: 0.25rem;
}
.kpi-icon svg {
    width: 20px;
    height: 20px;
    transition: var(--ease);
}

.kpi-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 120px;
    height: 120px;
    box-shadow: var(--shadow-sm);
    transition: var(--ease);
    cursor: grab;
}
.kpi-card:active { cursor: grabbing; }
.kpi-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    border: 1.5px dashed var(--accent);
    z-index: 100;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); border-color: rgba(255,255,255,0.1); }

.accent-green .kpi-icon { background: rgba(16,185,129,0.15); color: var(--accent); }
.accent-amber .kpi-icon { background: rgba(245,158,11,0.15);  color: var(--amber); }
.accent-blue  .kpi-icon { background: rgba(59,130,246,0.15);  color: var(--blue); }
.accent-red   .kpi-icon { background: rgba(239,68,68,0.15);   color: var(--red); }
.accent-orange .kpi-icon { background: rgba(249,115,22,0.15);  color: var(--orange); }
.accent-purple .kpi-icon { background: rgba(139,92,246,0.15);  color: var(--purple); }
.accent-blue2 .kpi-icon { background: rgba(37,99,235,0.15);   color: var(--blue); }

.kpi-label { font-size: 0.65rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 0.2rem; line-height: 1.1; }
.kpi-value { font-size: 1.1rem; font-weight: 700; }

/* ============================================================
   DASHBOARD GRID
   ============================================================ */
/* ============================================================
   DASHBOARD GRID
   ============================================================ */
/* ============================================================
   DASHBOARD MODULAR GRID
   ============================================================ */
.dash-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: start;
}

/* Base Panel Modular */
.panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 18px; padding: 1.25rem 1.5rem;
    backdrop-filter: var(--blur);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: grab;
    
    display: flex;
    flex-direction: column;
    
    /* Resizable Support */
    resize: both;
    overflow: auto;
    min-width: 280px;
    min-height: 200px;
}
.panel:active { cursor: grabbing; }
.panel.dragging { opacity: 0.4; transform: scale(0.98); border: 2px dashed var(--accent); }

.panel-ops      { flex: 0 1 auto; width: 600px; min-height: 450px; }
.panel-cobranza { flex: 0 1 auto; width: 300px; }
.panel-stock    { flex: 0 1 auto; width: 300px; }
.panel-tasks    { flex: 0 1 auto; width: 300px; }

.panel .table-wrap {
    flex: 1 1 auto;
    overflow-y: auto;
}

@media (max-width: 1100px) {
    .panel-ops { flex: 1 1 100% !important; width: 100% !important; }
}

.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.1rem;
}
.panel-header h2 { font-size: 0.95rem; font-weight: 600; }

.badge {
    background: rgba(255,255,255,0.07); color: var(--text-2);
    font-size: 0.7rem; font-weight: 600;
    padding: 0.2rem 0.6rem; border-radius: 99px;
    border: 1px solid var(--panel-border);
}

/* ============================================================
   COBRANZA PANEL
   ============================================================ */
.cobranza-bar-wrap { margin-bottom: 1rem; }
.cobranza-bar-track {
    width: 100%; height: 10px;
    background: rgba(239,68,68,0.2);
    border-radius: 99px; overflow: hidden; margin-bottom: 0.4rem;
}
.cobranza-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #34d399);
    border-radius: 99px;
    transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.cobranza-bar-labels { display: flex; justify-content: space-between; font-size: 0.72rem; }
.label-cobrado   { color: var(--accent); }
.label-pendiente { color: var(--red); }

.cobranza-list { display: flex; flex-direction: column; gap: 0.55rem; flex: 1 1 auto; overflow-y: auto; padding-right: 4px; }
.cobranza-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem 0.7rem; border-radius: 9px;
    background: rgba(255,255,255,0.03); transition: var(--ease);
}
.cobranza-row:hover { background: rgba(255,255,255,0.06); }
.cobranza-row .cliente { flex:1; font-size: 0.82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cobranza-row .factura { font-size: 0.72rem; color: var(--text-2); }
.cobranza-row .monto   { font-size: 0.82rem; font-weight: 700; padding: 0.18rem 0.5rem; border-radius: 7px; background: rgba(239,68,68,0.12); color: var(--red); white-space: nowrap; }
.cobranza-row .monto.cobrado { background: rgba(16,185,129,0.1); color: var(--accent); }

/* ============================================================
   STOCK PANEL
   ============================================================ */
.stock-list { display: flex; flex-direction: column; gap: 0.6rem; flex: 1 1 auto; overflow-y: auto; padding-right: 4px; }
.stock-item {
    display: flex; flex-direction: column; gap: 0.3rem;
    padding: 0.55rem 0.7rem; border-radius: 9px;
    background: rgba(255,255,255,0.03); transition: var(--ease);
}
.stock-item:hover { background: rgba(255,255,255,0.06); }
.stock-item-header { display: flex; justify-content: space-between; align-items: center; }
.stock-item-name { font-size: 0.8rem; font-weight: 500; }
.stock-qty { font-size: 0.75rem; font-weight: 700; padding: 0.18rem 0.5rem; border-radius: 6px; }
.qty-ok       { background: rgba(16,185,129,0.12); color: var(--accent); }
.qty-low      { background: rgba(245,158,11,0.12);  color: var(--amber); }
.qty-critical { background: rgba(239,68,68,0.12);   color: var(--red); }
.stock-bar-track { width: 100%; height: 5px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; }
.stock-bar-fill  { height: 100%; border-radius: 99px; transition: width 0.6s ease; }
.fill-ok       { background: var(--accent); }
.fill-low      { background: var(--amber); }
.fill-critical { background: var(--red); }

/* ============================================================
   OPS LIST (dashboard)
   ============================================================ */
.ops-list { display: flex; flex-direction: column; }
.ops-row {
    display: grid;
    grid-template-columns: 40px minmax(80px, 1.2fr) minmax(100px, 1.5fr) minmax(60px, 0.8fr) minmax(70px, 1fr) minmax(70px, 1fr) minmax(80px, 1fr);
    align-items: center; gap: 0.5rem;
    padding: 0.6rem 0.4rem;
    border-bottom: 1px solid var(--panel-border);
    font-size: 0.75rem; transition: var(--ease);
    width: 100%;
}
.ops-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops-row:last-child { border-bottom: none; }
.ops-row:hover { background: rgba(255,255,255,0.02); border-radius: 8px; }
.ops-row.ops-header { color: var(--text-2); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.ops-nro     { color: var(--text-2); font-size: 0.75rem; font-weight: 500; }
.ops-client  { color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; font-weight: 600; }
.ops-product { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-badge {
    display: inline-block; padding: 0.18rem 0.6rem;
    border-radius: 99px; font-size: 0.7rem; font-weight: 600; white-space: nowrap;
}
.s-despachado { background: rgba(16,185,129,0.12); color: var(--accent); border: 1px solid rgba(16,185,129,0.2); }
.s-proceso    { background: rgba(245,158,11,0.12);  color: var(--amber);  border: 1px solid rgba(245,158,11,0.2); }
.s-pendiente  { background: rgba(239,68,68,0.12);   color: var(--red);    border: 1px solid rgba(239,68,68,0.2); }

/* Cobro status */
.sc-pagado   { background: rgba(16,185,129,0.12); color: var(--accent); border: 1px solid rgba(16,185,129,0.2); }
.sc-pendiente { background: rgba(245,158,11,0.12); color: var(--amber);  border: 1px solid rgba(245,158,11,0.2); }
.sc-llamar   { background: rgba(59,130,246,0.12);  color: var(--blue);   border: 1px solid rgba(59,130,246,0.2); }

/* ============================================================
   OTHER VIEWS — controls & table
   ============================================================ */
.view-controls {
    display: flex; gap: 0.75rem; margin-bottom: 1.2rem; align-items: stretch;
}
.search-box {
    flex: 1; display: flex; align-items: center; gap: 0.6rem;
    background: var(--panel-bg); border: 1px solid var(--panel-border);
    border-radius: 12px; padding: 0 0.85rem;
    position: relative; transition: var(--ease);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(16,185,129,0.1); }
.search-box svg { color: var(--text-2); flex-shrink: 0; }
.search-box input {
    background: transparent; border: none; outline: none;
    color: var(--text-1); padding: 0.75rem 0; font-size: 0.875rem;
    width: 100%; font-family: inherit;
}
.btn-clear-search {
    background: rgba(255,255,255,0.05);
    border: none;
    color: var(--text-2);
    font-size: 1rem;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
    margin-left: 4px;
}
.btn-clear-search:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-1);
    transform: scale(1.1);
}
/* Mostrar solo cuando el input NO esté vacío */
.search-box input:not(:placeholder-shown) ~ .btn-clear-search {
    display: flex;
}
.filter-select {
    background: var(--panel-bg); border: 1px solid var(--panel-border);
    color: var(--text-1); border-radius: 10px; padding: 0 1rem;
    font-size: 0.875rem; font-family: 'Inter', sans-serif; cursor: pointer; outline: none;
}

.table-wrap { overflow-x: auto; width: 100%; position: relative; border-radius: 0 0 16px 16px; }
table { min-width: 1400px; width: 100%; border-collapse: collapse; table-layout: auto; }
thead th {
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--panel-border);
    border-right: 1px solid var(--panel-border);
    color: var(--text-2); font-size: 0.65rem;
    text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
    text-align: left; white-space: nowrap;
    position: relative; /* Para anclar el resizer */
}
thead th:last-child { border-right: none; }

/* Resizer handle */
.resizer {
    position: absolute;
    top: 0; right: 0;
    width: 5px; height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 10;
}
.resizer:hover {
    background: var(--accent);
    opacity: 0.5;
}

tbody tr { border-bottom: 1px solid var(--panel-border); transition: var(--ease); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.025); }
tbody tr.row-alt { background: rgba(255,255,255,0.03); }

tbody td {
    padding: 0.5rem 0.65rem; 
    font-size: 0.78rem; 
    vertical-align: middle; 
    border-right: 1px solid var(--panel-border);
    white-space: nowrap; /* Evita que los números se bajen a la siguiente línea */
    overflow: hidden; 
    text-overflow: ellipsis; /* Añade puntos suspensivos si el texto es muy largo */
}
tbody td:last-child { border-right: none; }

/* Estabilización de columnas */
.cell-input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    outline: none;
    color: inherit;
    font-size: inherit;
    font-family: inherit;
    border-radius: 4px;
    padding: 2px 4px;
    transition: var(--ease);
}
.cell-input:focus {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.15);
}

.cell-sm { min-width: 60px; width: 100%; }
.cell-md { min-width: 100px; width: 100%; }
.cell-lg { min-width: 150px; width: 100%; }
.cell-money { text-align: right; font-weight: 600; min-width: 105px; white-space: nowrap; }
.stock-qty { font-weight: 700; text-align: center; }
.profit-pos { color: var(--accent); font-weight: 600; }
.profit-neg { color: var(--red);    font-weight: 600; }
.text-muted { color: var(--text-2); }

/* Export button */
.btn-export {
    display: flex; align-items: center; gap: 0.4rem;
    background: rgba(16,185,129,0.1); color: var(--accent);
    border: 1px solid rgba(16,185,129,0.2); border-radius: 8px;
    padding: 0.35rem 0.85rem; font-size: 0.78rem; font-weight: 600;
    cursor: pointer; transition: var(--ease); font-family: 'Inter', sans-serif;
}
.btn-export:hover { background: rgba(16,185,129,0.2); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
    display: inline-flex; align-items: center; gap: 0.45rem;
    background: var(--accent); color: #fff; border: none;
    border-radius: 10px; padding: 0.65rem 1.1rem;
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
    transition: var(--ease); font-family: 'Inter', sans-serif; white-space: nowrap;
}
.btn-primary:hover { background: #0eaa74; }
.btn-outline {
    display: inline-flex; align-items: center; gap: 0.45rem;
    background: transparent; color: var(--text-2);
    border: 1px solid var(--panel-border); border-radius: 10px;
    padding: 0.65rem 1.1rem; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: var(--ease); font-family: 'Inter', sans-serif;
}
.btn-outline:hover { background: rgba(255,255,255,0.05); color: var(--text-1); }

/* Action buttons inside table rows */
.btn-row-action {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.25rem 0.45rem; border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04); color: var(--text-2);
    cursor: pointer;
    transition: var(--ease); font-family: 'Inter', sans-serif; white-space: nowrap;
    margin-right: 4px;
    vertical-align: middle;
}
.btn-row-action:hover           { background: rgba(255,255,255,0.08); color: var(--text-1); }
.btn-row-action.btn-cobro:hover { background: rgba(245,158,11,0.12);  color: var(--amber); border-color: rgba(245,158,11,0.25); }
.btn-row-action.btn-edit:hover  { background: rgba(16,185,129,0.12);  color: var(--accent); border-color: rgba(16,185,129,0.25); }
.btn-row-action.btn-msg:hover   { background: rgba(59,130,246,0.12);   color: var(--blue);   border-color: rgba(59,130,246,0.25); }
.btn-row-action.btn-del:hover   { background: rgba(239,68,68,0.12);    color: var(--red);    border-color: rgba(239,68,68,0.25); }

/* Force action cells to be overflow-visible so they never render "..." */
.cell-actions,
tbody td:last-child {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
}

/* Selection Support */
.row-selector {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.bulk-summary {
    position: sticky;
    bottom: -1rem;
    left: 0;
    right: 0;
    background: var(--accent);
    color: white;
    padding: 0.8rem 1.2rem;
    border-radius: 0 0 16px 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    z-index: 100;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.bulk-info strong {
    font-size: 1.1rem;
    margin-left: 5px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}


/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65); backdrop-filter: blur(5px);
    z-index: 5000; opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal {
    position: fixed; inset: 0; z-index: 6000;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem; pointer-events: none;
}
.modal.open { pointer-events: all; }

/* Forzar prioridad máxima cuando hay confirmación */
body.confirm-open #modal-confirm { z-index: 120000 !important; }
body.confirm-open #modal-confirm .modal-card { opacity: 1 !important; transform: scale(1) !important; }
#modal-doc-preview { z-index: 8000 !important; }

.modal-card {
    background: rgba(14, 20, 34, 0.98);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px; 
    width: 95%; 
    max-width: var(--modal-default-w);
    max-height: 90vh; 
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 90px rgba(0,0,0,0.65);
    transform: scale(0.93) translateY(10px);
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1), opacity 0.26s ease;
    opacity: 0;
    
    /* Resizable logic */
    resize: both;
    overflow: auto;
    min-width: 300px;
    min-height: 150px;
}
.modal.open .modal-card { transform: scale(1) translateY(0); opacity: 1; }

/* Variante Panel Lateral (Drawer) */
.modal-card-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 500px;
    max-width: 90vw;
    border-radius: 0;
    border-left: 1px solid var(--panel-border);
    transform: translateX(100%) !important;
    max-height: 100vh;
}
.modal.open .modal-card-drawer {
    transform: translateX(0) !important;
}

/* Variante Pantalla Completa (SII Assistant) */
.modal-card-full {
    width: 95vw;
    max-width: 1600px;
    height: 92vh;
    border-radius: 24px;
    transform: scale(0.95) translateY(20px) !important;
}
.modal.open .modal-card-full {
    transform: scale(1) translateY(0) !important;
}

.modal-card-sm { max-width: 460px; }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--panel-border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
    background: rgba(255,255,255,0.07); border: none; color: var(--text-2);
    border-radius: 8px; padding: 0.35rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: var(--ease);
}
.modal-close:hover { background: rgba(255,255,255,0.13); color: var(--text-1); }

.modal-body {
    padding: 1rem 1.25rem;
    display: flex; flex-direction: column; gap: 0.75rem;
}
.modal-footer {
    display: flex; justify-content: flex-end; gap: 0.75rem;
    padding: 1rem 1.25rem; border-top: 1px solid var(--panel-border);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.7rem; color: var(--text-2); font-weight: 500; }
.form-group input,
.form-group select,
.form-group textarea {
    background: #1e293b; /* Fondo gris oscuro sólido */
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px; color: var(--text-1);
    font-size: 0.8rem; font-family: 'Inter', sans-serif;
    padding: 0.4rem 0.65rem; outline: none;
    transition: var(--ease); width: 100%;
}
.total-factura-inp { 
    color: #ef4444 !important; 
    font-weight: 800 !important; 
    font-size: 1.1rem !important;
    background: rgba(239, 68, 68, 0.05) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
    cursor: default;
}

select option {
    background-color: #0f172a; /* Fondo muy oscuro para las opciones */
    color: white;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    background: rgba(16,185,129,0.04);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.08);
}
.form-group input[readonly] { opacity: 0.45; cursor: default; }
.form-group textarea { resize: vertical; }
select { 
    cursor: pointer; 
    -webkit-appearance: none; 
    appearance: none; 
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem !important;
}

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.85rem; }

/* Calculated preview */

/* Ocultar flechas de inputs numéricos (Spinners) */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield !important;
}
.calc-preview {
    display: flex; gap: 0;
    background: rgba(16,185,129,0.06);
    border: 1px solid rgba(16,185,129,0.15);
    border-radius: 8px; overflow: hidden;
}
.calc-item { flex: 1; padding: 0.45rem 0.75rem; }
.calc-sep { border-left: 1px solid rgba(16,185,129,0.15); }
.calc-item span  { font-size: 0.65rem; color: var(--text-2); display: block; margin-bottom: 0.1rem; }
.calc-item strong { font-size: 0.85rem; font-weight: 700; color: var(--accent); }

/* ============================================================
   COBRO MODAL
   ============================================================ */
.cobro-op-info {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border);
    border-radius: 10px; padding: 0.875rem 1rem;
    display: flex; flex-direction: column; gap: 0.3rem;
}
.cobro-op-info .ci-cliente { font-weight: 600; font-size: 0.9rem; }
.cobro-op-info .ci-detail  { font-size: 0.78rem; color: var(--text-2); }
.cobro-op-info .ci-monto   { font-size: 0.875rem; font-weight: 700; color: var(--red); margin-top: 0.15rem; }
.cobro-op-info .ci-monto.ok { color: var(--accent); }

/* Radio group for cobro */
.radio-group { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.6rem; }
.radio-opt input[type="radio"] { display: none; }
.radio-label-card {
    display: flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.65rem 0.5rem; border-radius: 10px;
    border: 1.5px solid rgba(255,255,255,0.08);
    font-size: 0.78rem; font-weight: 600; cursor: pointer;
    transition: var(--ease); text-align: center;
}
.radio-label-card:hover { background: rgba(255,255,255,0.05); }
.rc-pagado   { color: var(--accent); }
.rc-pendiente { color: var(--amber); }
.rc-llamar   { color: var(--blue); }
.radio-opt input:checked + .radio-label-card.rc-pagado   { background: rgba(16,185,129,0.15); border-color: var(--accent); }
.radio-opt input:checked + .radio-label-card.rc-pendiente { background: rgba(245,158,11,0.15); border-color: var(--amber); }
.radio-opt input:checked + .radio-label-card.rc-llamar   { background: rgba(59,130,246,0.15); border-color: var(--blue); }

/* ============================================================
   ITEMS EDITOR (Modal Op)
   ============================================================ */
.items-editor { margin: 0.5rem 0; }
.items-table { 
    width: auto; 
    min-width: auto; /* Override global 1400px min-width */
    border-collapse: separate; 
    border-spacing: 0 4px; 
    margin-top: 0.4rem;
}
.items-table th { 
    font-size: 0.65rem; color: var(--text-3); text-transform: uppercase; 
    padding: 0 4px; text-align: left;
}
.items-table td { vertical-align: middle; padding: 0; }
.items-table .cell-input { 
    padding: 0.3rem 0.4rem; 
    font-size: 0.75rem; 
    width: 100%; 
    box-sizing: border-box; 
    border-radius: 0; /* Más rectangular para que parezcan juntos */
    border-width: 0 0 1px 0; /* Solo línea abajo para mayor limpieza */
    background: transparent;
}
.it-cod { width: 50px; }
.it-prod { width: 220px; }
.it-cant { width: 45px; text-align: center; }
.it-neto, .it-costo { width: 90px; text-align: right; }
.btn-del-item {
    background: rgba(239, 68, 68, 0.1); color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px; width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--ease);
}
.btn-del-item:hover { background: rgba(239, 68, 68, 0.2); transform: scale(1.05); }

/* ============================================================
   SCROLLBAR (Mejorada para fácil agarre)
   ============================================================ */
::-webkit-scrollbar {
    width: 18px;
    height: 18px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb { 
    background: rgba(255, 255, 255, 0.3); 
    border-radius: 10px;
    border: 3px solid transparent; /* Más gruesa visualmente */
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { 
    background: var(--accent, #3b82f6); /* Color de realce al pasar el cursor */
    background-clip: content-box;
}
::-webkit-scrollbar-corner { background: transparent; }

/* ============================================================
   CLIENT SPREADSHEET TABLE
   ============================================================ */

/* Row highlight — llamar hoy */
.row-llamar-hoy { background: rgba(245, 158, 11, 0.06) !important; }
.row-llamar-hoy:hover { background: rgba(245, 158, 11, 0.1) !important; }
.row-llamar-hoy td:first-child { border-left: 3px solid var(--amber); }

/* Inline editable inputs */
.cell-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-1);
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    padding: 0.3rem 0.45rem;
    outline: none;
    transition: var(--ease);
    width: 100%;
    /* min-width eliminado para evitar desbordamientos */
}
.cell-input:hover  { border-color: rgba(255,255,255,0.12); background: rgba(255,255,255,0.03); }
.cell-input:focus  { border-color: var(--accent); background: rgba(16,185,129,0.05); box-shadow: 0 0 0 2px rgba(16,185,129,0.08); }

.cell-select {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-1);
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    padding: 0.3rem 0.35rem;
    outline: none;
    cursor: pointer;
    transition: var(--ease);
    width: 100%;
}
.cell-select:hover { border-color: rgba(255,255,255,0.12); background: rgba(255,255,255,0.04); }
.cell-select:focus { border-color: var(--accent); background: rgba(16,185,129,0.05); }

/* Column width helpers */
.cell-sm   { min-width: 90px;  max-width: 110px; }
.cell-md   { min-width: 120px; max-width: 160px; }
.cell-lg   { min-width: 160px; max-width: 220px; }
.cell-date { min-width: 130px; }

.cell-n { font-size: 0.75rem; color: var(--text-2); font-weight: 600; }
.cell-money { color: var(--accent); font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
.cell-fecha-fact { color: var(--text-2); font-size: 0.8rem; white-space: nowrap; }

/* Observation Button & Tooltip */
.btn-obs-small {
    background: rgba(255,255,255,0.05);
    border: 1.2px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-3);
    transition: all 0.2s ease;
    position: relative;
    margin: 0 auto;
}
.btn-obs-small:hover {
    background: rgba(16,185,129,0.15);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}
.btn-obs-small[data-has-obs="true"] {
    color: var(--accent);
    background: rgba(16,185,129,0.08);
}
.btn-obs-small::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.72rem;
    color: #f8fafc;
    white-space: pre-wrap;
    width: max-content;
    max-width: 240px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    line-height: 1.4;
    font-weight: 400;
}
.btn-obs-small:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
/* Triangulito del globo */
.btn-obs-small::before {
    content: '';
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 1001;
}
.btn-obs-small:hover::before {
    opacity: 1;
}

/* ============================================================
   DATE FILTER (Clientes)
   ============================================================ */
.date-filter-wrap {
    display: flex; align-items: center; gap: 0.5rem;
    background: var(--panel-bg); border: 1px solid var(--panel-border);
    border-radius: 10px; padding: 0 0.875rem;
    white-space: nowrap;
}
.date-filter-label { font-size: 0.75rem; color: var(--text-2); font-weight: 500; }
.date-filter-wrap input[type="date"] {
    background: transparent; border: none; outline: none;
    color: var(--text-1); font-size: 0.8rem;
    font-family: 'Inter', sans-serif; padding: 0.6rem 0;
    cursor: pointer;
}

/* Forzar color scheme oscuro y blanco en todos los iconos de calendario de tipo date */
input[type="date"] {
    color-scheme: dark;
}
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(1) brightness(2); /* Blanco brillante */
}

.btn-hoy {
    background: rgba(245,158,11,0.12); color: var(--amber);
    border: 1px solid rgba(245,158,11,0.25); border-radius: 6px;
    padding: 0.25rem 0.6rem; font-size: 0.72rem; font-weight: 700;
    cursor: pointer; font-family: 'Inter', sans-serif; transition: var(--ease);
    white-space: nowrap;
}
.btn-hoy:hover { background: rgba(245,158,11,0.22); }
.btn-todos-link {
    background: transparent; color: var(--text-2); border: none;
    font-size: 0.72rem; font-weight: 500; cursor: pointer;
    font-family: 'Inter', sans-serif; transition: var(--ease); padding: 0;
}
.btn-todos-link:hover { color: var(--text-1); }

/* Inline Select (Table) */
.inline-select {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-1);
    font-size: 0.72rem;
    padding: 0 5px;
    height: 20px;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    transition: var(--ease);
    line-height: normal;
}
.inline-select:hover { background: rgba(255,255,255,0.1); }
.inline-select.sc-pagado { color: var(--accent); border-color: rgba(16,185,129,0.3); }
.inline-select.sc-pendiente { color: var(--red); border-color: rgba(239,68,68,0.3); }
.inline-select.sc-llamar { color: var(--blue); border-color: rgba(59,130,246,0.3); }

.inline-select.s-pendiente { color: var(--orange); border-color: rgba(245,158,11,0.3); }
.inline-select.s-enproceso { color: var(--blue); border-color: rgba(59,130,246,0.3); }
.inline-select.s-despachado { color: var(--accent); border-color: rgba(16,185,129,0.3); }

.inline-date {
    background: transparent;
    border: none;
    color: var(--text-2);
    font-size: 0.8rem;
    font-family: inherit;
    width: 100%;
    cursor: pointer;
    outline: none;
    padding: 2px;
}
.inline-date::-webkit-calendar-picker-indicator { 
    filter: invert(1) brightness(2); 
    cursor: pointer;
}
.inline-date:hover { color: var(--text-1); }

/* ============================================================
   RADIO GROUPS (Cobro Modal)
   ============================================================ */
.modal-card-lg { width: 100%; max-width: 760px; }

/* ============================================================
   GESTOR DE MENSAJES
   ============================================================ */
.templates-list {
    display: flex;
    flex-direction: column;
}
.tpl-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--panel-border);
    cursor: pointer;
    transition: var(--ease);
}
.tpl-item:hover {
    background: rgba(255,255,255,0.03);
}
.tpl-item.active {
    background: rgba(16,185,129,0.06);
    border-left: 3px solid var(--accent);
}
.tpl-name {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 0.25rem;
}
.tpl-desc {
    font-size: 0.75rem;
    color: var(--text-2);
}

.msg-preview-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 1.5rem;
}
.msg-vars-hint {
    margin-top: 1.25rem;
    font-size: 0.7rem;
    color: var(--text-2);
    padding: 0.75rem;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
}
.msg-vars-hint code {
    color: var(--accent);
    background: rgba(16,185,129,0.1);
    padding: 2px 4px;
    border-radius: 4px;
    margin: 0 2px;
}
.cell-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}
.quick-msg-btns {
    display: flex;
    opacity: 0;
    transition: var(--ease);
}
tr:hover .quick-msg-btns {
    opacity: 1;
}
.quick-msg-btns button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}
.quick-msg-btns button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* ===================== IMPORT TRACKING MODULE ===================== */
#imports-view .panel {
    background: var(--bg-1);
    border: 1px solid var(--panel-border);
}

.imp-badge {
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.imp-transit { background: rgba(59, 130, 246, 0.1); color: var(--blue); border: 1px solid rgba(59, 130, 246, 0.2); }
.imp-port    { background: rgba(245, 158, 11, 0.1); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.2); }
.imp-truck   { background: rgba(16, 185, 129, 0.1); color: var(--accent); border: 1px solid rgba(16, 185, 129, 0.2); }
.imp-done    { background: rgba(107, 114, 128, 0.1); color: var(--text-2); border: 1px solid rgba(107, 114, 128, 0.2); }

#imp-proc-body .cell-input {
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.2s;
    width: 100%;
}

#imp-proc-body .cell-input:hover, #imp-proc-body .cell-input:focus {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
}

.imp-timeline-point {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-2);
    margin-bottom: 2px;
}

.imp-timeline-point .point-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

/* ============================================================
   NOTIFICATIONS
   ============================================================ */
.notification-wrap { position: relative; }
.btn-icon {
    background: var(--panel-bg); border: 1px solid var(--panel-border);
    color: var(--text-2); border-radius: 8px; width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: var(--ease); position: relative;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

.notif-badge {
    position: absolute; top: -5px; right: -5px;
    background: var(--red); color: #fff; font-size: 0.65rem; font-weight: 700;
    min-width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg);
}

.notif-panel {
    position: absolute; top: 48px; right: 0; width: 320px;
    background: #0e1422; border: 1px solid var(--panel-border);
    border-radius: 16px; box-shadow: 0 15px 45px rgba(0,0,0,0.5);
    z-index: 1000; overflow: hidden; animation: slideUp 0.25s ease-out;
}
.notif-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--panel-border);
    background: rgba(255,255,255,0.02);
}
.notif-header span { font-weight: 600; font-size: 0.875rem; }
.notif-list { max-height: 400px; overflow-y: auto; }
.notif-item {
    display: flex; gap: 0.8rem; padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--panel-border); transition: var(--ease);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: rgba(255,255,255,0.03); }
.notif-ico {
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.ni-warning { background: rgba(239,68,68,0.12); color: var(--red); }
.ni-pending { background: rgba(245,158,11,0.12);  color: var(--amber); }

.notif-content { display: flex; flex-direction: column; gap: 0.2rem; }
.notif-title { font-size: 0.82rem; font-weight: 600; color: var(--text-1); }
.notif-desc  { font-size: 0.72rem; color: var(--text-2); line-height: 1.3; }

.text-link {
    background: none; border: none; color: var(--accent);
    font-size: 0.72rem; font-weight: 600; cursor: pointer; padding: 0;
}
.text-link:hover { text-decoration: underline; }

/* ============================================================
   SII STATUS BADGES
   ============================================================ */
.sii-emitida   { background: rgba(16,185,129,0.12); color: var(--accent); border: 1px solid rgba(16,185,129,0.25); }
.sii-pendiente { background: rgba(239,68,68,0.12);   color: var(--red);    border: 1px solid rgba(239,68,68,0.25); }
.sii-none      { background: rgba(148,163,184,0.1);  color: var(--text-2); border: 1px solid rgba(148,163,184,0.15); }

/* Ajuste para inline selector SII */
.inline-select.sii-pendiente { border-color: var(--red); color: var(--red); background-color: rgba(239,68,68,0.05); }
.inline-select.sii-emitida   { border-color: var(--accent); color: var(--accent); background-color: rgba(16,185,129,0.05); }

/* ============================================================
   SII INVOICE SUMMARY STYLES
   ============================================================ */
.sii-factura-box { font-family: 'Inter', sans-serif; line-height: 1.4; color: #1e293b; }
.sii-header { display: flex; justify-content: space-between; margin-bottom: 2rem; }
.sii-emisor { width: 60%; }
.sii-emisor .razon { font-size: 1.2rem; font-weight: 800; color: #0f172a; margin-bottom: 5px; text-transform: uppercase; }
.sii-emisor .datos { font-size: 0.85rem; color: #64748b; line-height: 1.5; }

.sii-folio-box { 
    width: 35%; border: 3px solid #dc2626; padding: 1.25rem; 
    text-align: center; color: #dc2626; font-weight: 700; border-radius: 4px;
    background: #fff;
}
.sii-folio-box .rut { font-size: 1.15rem; margin-bottom: 0.5rem; }
.sii-folio-box .tipo { font-size: 0.85rem; text-transform: uppercase; margin-bottom: 0.5rem; border-top: 2px solid #dc2626; border-bottom: 2px solid #dc2626; padding: 0.5rem 0; line-height: 1.2; }
.sii-folio-box .folio { font-size: 1.6rem; margin-top: 0.25rem; }

.sii-info-receptor { 
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; 
    padding: 1.25rem; margin-bottom: 2rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem;
}
.sii-info-receptor .item { display: flex; flex-direction: column; }
.sii-info-receptor strong { color: #94a3b8; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.sii-info-receptor span { font-size: 0.9rem; font-weight: 600; color: #334155; }

.sii-table { width: 100%; border-collapse: collapse; margin-bottom: 2rem; }
.sii-table th { background: #f1f5f9; text-align: left; padding: 0.85rem 0.75rem; font-size: 0.75rem; text-transform: uppercase; color: #64748b; border-bottom: 2px solid #e2e8f0; letter-spacing: 0.5px; }
.sii-table td { padding: 0.85rem 0.75rem; font-size: 0.9rem; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.sii-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.sii-footer { display: flex; justify-content: flex-end; }
.sii-totales { width: 260px; background: #f8fafc; padding: 1rem; border-radius: 8px; border: 1px solid #e2e8f0; }
.sii-total-row { display: flex; justify-content: space-between; padding: 0.6rem 0; border-bottom: 1px solid #f1f5f9; }
.sii-total-row:last-child { border-bottom: none; }
.sii-total-row.grand-total { border-top: 2px solid #e2e8f0; margin-top: 5px; padding-top: 1rem; font-size: 1.3rem; font-weight: 800; color: #0f172a; }
.sii-total-row span:first-child { color: #64748b; font-weight: 600; font-size: 0.85rem; }
.sii-total-row span:last-child { font-weight: 700; color: #1e293b; }

/* ============================================================
   ASISTENTE SPLIT-SCREEN (ASISTIDA POR EL SII)
   ============================================================ */
.split-assistant {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
}

.assistant-header-sticky {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.assistant-main {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.assistant-footer-sticky {
    padding: 1.5rem 2rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.assistant-section {
    margin-bottom: 0.75rem;
}

.assistant-section h3 {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.5rem;
}

.copy-field {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.45rem 0.75rem;
    margin-bottom: 0.3rem;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    overflow: hidden;
}

.copy-field:hover {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.08);
}

.copy-field:active {
    transform: scale(0.98);
}

.copy-btn {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    background: #fff;
    border: 1.5px solid #e2e8f0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
}

.copy-field:hover .copy-btn {
    border-color: var(--accent);
    color: var(--accent);
}

.copy-btn:hover {
    background: var(--accent);
    color: white !important;
}

.copy-field strong {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.copy-field span {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    padding-right: 35px;
    word-break: break-all;
    display: block;
    line-height: 1.3;
}

.btn-sii-big {
    background: #004795;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 1rem;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn-sii-big:hover {
    background: #003670;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 71, 149, 0.35);
}

#assistant-total-display {
    text-align: center;
}

/* Animación de feedback al copiar */
@keyframes copied {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); background: rgba(16, 185, 129, 0.05); }
    100% { transform: scale(1); }
}
.field-copied {
    animation: copied 0.4s ease;
    border-color: var(--accent) !important;
}

.field-done {
    opacity: 0.5;
    filter: grayscale(0.8);
    background: #f1f5f9 !important;
    border-style: dashed !important;
    cursor: pointer; /* Mantener interactividad */
}

/* ============================================================
   EXPANDABLE OBSERVATIONS
   ============================================================ */
.expandable-obs {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
    color: var(--text-2);
}

.expandable-obs:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-1);
}

.expandable-obs.expanded {
    white-space: normal;
    max-width: 350px;
    overflow: visible;
    background: rgba(16, 185, 129, 0.08);
    color: var(--text-1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10;
    position: relative;
}

/* ============================================================
   NATIVE INBOX STYLES
   ============================================================ */
.mail-list {
    display: flex;
    flex-direction: column;
}

/* Maximizar espacio en webmail */
#webmail-view.sidebar-hidden .dash-grid {
    grid-template-columns: 1fr !important;
}
#webmail-view.sidebar-hidden .dash-grid > .panel:first-child {
    display: none !important;
}

.mail-item {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--panel-border);
    cursor: pointer;
    transition: var(--ease);
    border-left: 4px solid transparent;
    overflow-x: hidden;
}

.mail-item:hover {
    background: rgba(16, 185, 129, 0.03);
}

.mail-item.unread {
    background: rgba(16, 185, 129, 0.05);
    border-left-color: var(--accent);
}

.mail-item.expanded {
    padding: 0;
    background: #fff !important;
}

.mail-item.expanded .mail-top, 
.mail-item.expanded .mail-body-preview {
    padding: 1.25rem 1.5rem;
}

.mail-item.expanded .mail-from,
.mail-item.expanded .mail-sub,
.mail-item.expanded .mail-date {
    color: #334155 !important;
}

.mail-body-full {
    width: 100% !important;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.nav-separator {
    height: 1.5px;
    background: rgba(255,255,255,0.06);
    margin: 1.2rem 1rem;
    border-radius: 2px;
}

.mail-html-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.mail-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.mail-from {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-1);
}

.mail-date {
    font-size: 0.75rem;
    color: var(--text-3);
}

.mail-sub {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 4px;
}

.mail-body-preview {
    font-size: 0.8rem;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item-mail {
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.nav-item-mail:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.3);
}

.nav-item-mail.active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-color: var(--accent);
    box-shadow: 0 0 25px -5px var(--accent-glow);
}

.nav-item-mail.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--accent);
    box-shadow: 2px 0 10px var(--accent-glow);
}

.mail-acc-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.mail-acc-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mail-acc-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-1);
}

.mail-acc-user {
    font-size: 0.72rem;
    color: var(--text-2);
    opacity: 0.7;
}

.active-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.btn-edit-mail {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-3);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.btn-edit-mail:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-1);
    opacity: 1;
    transform: scale(1.05);
}

.nav-item-mail.active .mail-acc-label {
    color: var(--accent);
}

.unread-badge {
    background: var(--red);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
    margin-left: 8px;
}

/* ============================================================
   TASK LIST PANEL
   ============================================================ */
.panel-tasks {
    display: flex;
    flex-direction: column;
}

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.task-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--ease);
}

.task-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.task-item.task-done {
    opacity: 0.6;
    border-color: rgba(16, 185, 129, 0.2);
}

.task-top {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.task-desc {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-1);
    font-size: 0.85rem;
    font-family: inherit;
    resize: none;
    outline: none;
    padding: 0;
    line-height: 1.4;
}

.task-item.task-done .task-desc {
    text-decoration: line-through;
    color: var(--text-3);
}

.task-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.task-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.task-resp-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-2);
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
}

.task-status-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-2);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--ease);
}

.task-status-btn.pending {
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--amber);
}

.task-status-btn.done {
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--accent);
    background: rgba(16, 185, 129, 0.1);
}

.task-date {
    font-size: 0.65rem;
    color: var(--text-3);
}

.btn-del-task {
    background: transparent;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: var(--ease);
}

.btn-del-task:hover {
    color: var(--red);
}

.tasks-list-expanded {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 5px;
}

.tasks-list-expanded .task-item {
    background: rgba(255, 255, 255, 0.04);
    padding: 15px;
    border-radius: 12px;
}

.tasks-list-expanded .task-desc {
    font-size: 1rem;
    min-height: 60px;
}

/* ============================================================
   INTEGRATED MAIL COMPOSE
   ============================================================ */
.mail-compose-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: rgba(255, 255, 255, 0.02);
}

.compose-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
}

.compose-body {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.compose-body textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-1);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

.compose-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.1);
}

.compose-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1rem;
}

.compose-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 10000;
    pointer-events: none;
}

.toast {
    min-width: 280px;
    max-width: 400px;
    padding: 1rem 1.25rem;
    background: rgba(16, 22, 35, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    pointer-events: auto;
    animation: toast-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: all 0.3s ease;
}

.toast.fade-out {
    opacity: 0;
    transform: translateX(30px);
}

.toast-ico {
    width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}

.toast-success .toast-ico { background: rgba(16, 185, 129, 0.15); color: var(--accent); }
.toast-error .toast-ico   { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.toast-info .toast-ico    { background: rgba(59, 130, 246, 0.15); color: var(--blue); }

.toast-msg {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-1);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(50px) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

/* Tabs for Notebooks */
.templates-list { display: flex; flex-direction: column; gap: 0.5rem; }
.template-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1rem;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px; cursor: pointer; transition: var(--ease);
}
.template-item:hover { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.1); }
.template-item.active { background: rgba(59,130,246,0.1); border-color: var(--blue); }



/* Context Menu Overrides */
.context-menu {
    position: absolute;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 1000;
    min-width: 180px;
}
.cm-item {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    color: var(--text-1);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}
.cm-item:hover { background: rgba(255,255,255,0.05); }
.cm-separator {
    height: 1px;
    background: var(--panel-border);
    margin: 0.3rem 0;
}



/* Communications Center Styles */
.comm-item-card:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    border-left: 3px solid var(--accent);
}
.comm-item-card.active {
    background: rgba(59, 130, 246, 0.1) !important;
    border-left: 3px solid var(--blue);
}

#comm-preview-content {
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}




/* ===================== WEBMAIL (ROUNDCUBE STYLE) ===================== */
#mail-view {
    display: none;
    height: calc(100vh - 100px);
    overflow: hidden;
    padding: 0 !important;
    background: var(--bg-1);
}

#mail-view.active {
    display: flex;
}

.rc-layout {
    display: grid;
    grid-template-columns: 60px 220px 350px 1fr;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Sidebar Bar */
.rc-sidebar {
    background: #1a222d;
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 15px;
}

.rc-compose-btn {
    width: 40px;
    height: 40px;
    background: var(--blue);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ease);
}

.rc-compose-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.rc-compose-btn span { display: none; }

.rc-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

.rc-nav-item {
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: var(--ease);
}

.rc-nav-item span {
    font-size: 10px;
    font-weight: 500;
}

.rc-nav-item:hover, .rc-nav-item.active {
    color: white;
    background: rgba(255,255,255,0.05);
}

.rc-nav-item.active {
    color: var(--blue);
}

/* Folders Col */
.rc-folders-col {
    background: #1d2633;
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
}

.rc-account-header {
    padding: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.rc-account-header select {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
}

.rc-folder-list {
    list-style: none;
    padding: 10px 0;
}

.rc-folder-list li {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: var(--ease);
}

.rc-folder-list li svg { opacity: 0.5; }

.rc-folder-list li:hover {
    background: rgba(255,255,255,0.03);
    color: white;
}

.rc-folder-list li.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--blue);
    font-weight: 600;
    border-left: 3px solid var(--blue);
}

/* List Col */
.rc-list-col {
    background: var(--bg-1);
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
}

.rc-list-toolbar {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.rc-search-wrap {
    position: relative;
    width: 100%;
}

.rc-search-wrap input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 8px 15px 8px 35px;
    color: white;
    font-size: 0.85rem;
    outline: none;
}

.rc-search-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.4;
}

.rc-messages-container {
    flex: 1;
    overflow-y: auto;
}

.rc-msg-item {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer;
    transition: var(--ease);
    position: relative;
}

.rc-msg-item:hover {
    background: rgba(255,255,255,0.02);
}

.rc-msg-item.active {
    background: rgba(59, 130, 246, 0.05);
}

.rc-msg-item.unread::before {
    content: " \;
 position: absolute;
 left: 5px;
 top: 50%;
 transform: translateY(-50%);
 width: 6px;
 height: 6px;
 background: var(--blue);
 border-radius: 50%;
}

.rc-msg-header {
 display: flex;
 justify-content: space-between;
 margin-bottom: 4px;
}

.rc-msg-from {
 font-weight: 600;
 font-size: 0.88rem;
 color: var(--text-1);
 white-space: nowrap;
 overflow: hidden;
 text-overflow: ellipsis;
}

.rc-msg-date {
 font-size: 0.75rem;
 color: var(--text-3);
 flex-shrink: 0;
}

.rc-msg-subject {
 font-size: 0.82rem;
 color: var(--text-2);
 white-space: nowrap;
 overflow: hidden;
 text-overflow: ellipsis;
}

/* Preview Col */
.rc-preview-col {
 background: #141b25;
 display: flex;
 flex-direction: column;
 position: relative;
}

.rc-preview-placeholder {
 flex: 1;
 display: flex;
 align-items: center;
 justify-content: center;
}

.rc-logo-watermark {
 opacity: 0.1;
}

.rc-mail-read {
 height: 100%;
 display: flex;
 flex-direction: column;
}

.rc-mail-toolbar {
 padding: 10px 20px;
 background: #1a222d;
 border-bottom: 1px solid rgba(255,255,255,0.05);
 display: flex;
 gap: 10px;
}

.rc-mail-header {
 padding: 20px;
 border-bottom: 1px solid rgba(255,255,255,0.05);
}

.rc-mail-subject {
 font-size: 1.4rem;
 font-weight: 700;
 margin-bottom: 15px;
 color: var(--text-1);
}

.rc-mail-info {
 display: flex;
 align-items: center;
 gap: 12px;
}

.rc-mail-avatar {
 width: 40px;
 height: 40px;
 background: var(--accent);
 border-radius: 50%;
 display: flex;
 align-items: center;
 justify-content: center;
 font-weight: 700;
 color: white;
}

.rc-mail-body {
 flex: 1;
 padding: 25px;
 overflow-y: auto;
 font-size: 0.95rem;
 line-height: 1.6;
 color: var(--text-2);
 white-space: pre-wrap;
}

/* Responsive */
@media (max-width: 1100px) {
 .rc-layout { grid-template-columns: 60px 200px 300px 1fr; }
}

@media (max-width: 900px) {
 .rc-layout { grid-template-columns: 60px 1fr; }
 .rc-folders-col, .rc-list-col { display: none; }
}


.hidden-rc {
    display: none !important;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-3);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 10px 14px;
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: var(--ease);
}

.form-group input:focus {
    border-color: var(--blue);
    background: rgba(59, 130, 246, 0.05);
}

/* SISTEMA DE HOJAS (PERIODOS) */
.eco-periods-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    padding: 0 5px;
}
.period-tabs {
    display: flex;
    gap: 5px;
    background: rgba(0,0,0,0.2);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.05);
}
.period-tab {
    background: transparent;
    border: none;
    color: var(--text-2);
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.period-tab:hover {
    color: white;
    background: rgba(255,255,255,0.05);
}
.period-tab.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}
.btn-add-period {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    border: 1px dashed rgba(255,255,255,0.2);
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-add-period:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-color: var(--accent);
}

/* TABLA DE RESUMEN GENERAL */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.summary-table th {
    background: rgba(14, 20, 34, 0.5);
    color: var(--text-3);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    padding: 12px 15px;
    border-bottom: 1px solid var(--panel-border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.summary-table td {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.02);
}
.summary-table tr:hover {
    background: rgba(255,255,255,0.02);
}

/* MENÚ CONTEXTUAL PERSONALIZADO */
.custom-menu {
    position: fixed;
    z-index: 10000;
    background: rgba(14, 20, 34, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    min-width: 150px;
}
.custom-menu.hidden { display: none; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--text-2);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.menu-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}
.menu-item.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ============ ACCORDEON CARDS - CLIENTES POR VENDEDOR ============ */
.seller-accordion-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: 1.25rem 1.5rem;
    backdrop-filter: var(--blur);
    width: 640px;
    min-width: 640px;
    max-width: 100%;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    overflow: hidden;
}

.seller-accordion-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

.seller-accordion-card.expanded {
    border-color: var(--accent-glow);
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.seller-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.seller-avatar {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.seller-info {
    display: flex;
    flex-direction: column;
}

.seller-name {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-1);
    font-weight: 700;
}

.seller-sub {
    font-size: 0.75rem;
    color: var(--text-3);
    margin-top: 2px;
}

.seller-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: 1.5rem;
}

.badge-stat {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 99px;
    border: 1px solid transparent;
}

.badge-stat.stat-active {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent);
    border-color: rgba(16, 185, 129, 0.2);
}

.badge-stat.stat-inactive {
    background: rgba(245, 158, 11, 0.12);
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.2);
}

.accordion-chevron {
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.seller-accordion-card.expanded .accordion-chevron {
    transform: rotate(180deg);
    color: var(--text-1);
}

/* Cuerpo del Acordeón con Transición */
.seller-accordion-card .card-expandable-body {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, margin-top 0.3s ease;
    margin-top: 0;
}

.seller-accordion-card.expanded .card-expandable-body {
    max-height: 1000px;
    opacity: 1;
    margin-top: 1.25rem;
}

/* Indicadores de Actividad en la Tabla */
.activity-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    cursor: help;
}

.activity-dot.dot-active {
    background-color: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

.activity-dot.dot-inactive {
    background-color: var(--amber);
    box-shadow: 0 0 6px var(--amber);
}

/* ============================================================
   GRÁFICO DE TENDENCIA
   ============================================================ */
.chart-panel { padding: 1.5rem; }
.chart-container {
    position: relative;
    height: 320px;
    width: 100%;
    margin-top: 1rem;
}

/* ============================================================
   CALENDARIO DE VENCIMIENTOS
   ============================================================ */
.cal-grid-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 6px;
}
.cal-grid-header span {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 0;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.cal-cell {
    position: relative;
    min-height: 72px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 8px;
    cursor: default;
    transition: var(--ease);
}
.cal-cell:hover { background: rgba(255,255,255,0.06); }
.cal-cell-empty { background: transparent; border-color: transparent; }
.cal-day-num {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-1);
}
.cal-today {
    border-color: var(--accent) !important;
    background: rgba(16,185,129,0.08) !important;
}
.cal-today .cal-day-num { color: var(--accent); }
.cal-overdue {
    background: rgba(239,68,68,0.1) !important;
    border-color: rgba(239,68,68,0.4) !important;
    cursor: pointer;
}
.cal-soon {
    background: rgba(245,158,11,0.1) !important;
    border-color: rgba(245,158,11,0.4) !important;
    cursor: pointer;
}
.cal-paid {
    background: rgba(16,185,129,0.06) !important;
    border-color: rgba(16,185,129,0.3) !important;
    cursor: pointer;
}
.cal-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 50%;
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
}
.cal-overdue .cal-badge { background: var(--red); }
.cal-soon .cal-badge { background: var(--amber); }
.cal-legend-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* Popup del día */
.cal-popup {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--panel-bg);
    backdrop-filter: var(--blur);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    width: 380px;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 9000;
    box-shadow: 0 25px 50px rgba(0,0,0,0.6);
    padding: 1.2rem;
}
.cal-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-1);
}
.cal-popup-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--panel-border);
}
.cal-popup-row:last-child { border-bottom: none; }

/* ============================================================
   HISTORIAL Y RENTABILIDAD POR CLIENTE
   ============================================================ */
.client-history-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: var(--blur);
    animation: fadeInUp 0.3s ease;
}
.client-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
}
.client-history-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-1);
    margin: 0;
}
.client-history-kpis {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.ch-kpi {
    flex: 1;
    min-width: 120px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ch-kpi-label { font-size: 0.72rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.ch-kpi-val   { font-size: 1.05rem; font-weight: 700; color: var(--text-1); }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   DISEÑO RESPONSIVO — MÓVIL (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {

    :root {
        --sidebar-w: 0px;
        --header-h: 60px;
    }

    /* Sidebar: oculto por defecto, slide-in al activarse */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0; bottom: 0;
        width: 260px !important;
        z-index: 10000;
        transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
        box-shadow: 4px 0 30px rgba(0,0,0,0.6);
    }
    .sidebar.mobile-open { left: 0 !important; }

    /* Overlay al abrir sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.6);
        z-index: 9999;
    }
    .sidebar.mobile-open ~ .sidebar-overlay { display: block; }

    /* Botón hamburguesa en header */
    #btn-mobile-menu {
        display: flex !important;
        align-items: center; justify-content: center;
        width: 36px; height: 36px;
        background: rgba(255,255,255,0.05);
        border: 1px solid var(--panel-border);
        border-radius: 8px;
        color: var(--text-1);
        cursor: pointer;
        margin-right: 0.5rem;
        order: -1;
    }

    /* Main content: sin margen izquierdo de sidebar */
    .main-content { margin-left: 0 !important; }

    /* Header responsivo */
    .header { padding: 0 1rem; height: var(--header-h); }
    .header h1 { font-size: 1rem; }
    .header-right { gap: 8px; }

    /* Dashboard KPIs: columna única */
    #kpi-container {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    .kpi-card { width: 100% !important; min-width: unset !important; }

    /* Paneles del dashboard: columna única */
    #panel-container {
        flex-direction: column !important;
    }
    .panel { width: 100% !important; min-width: unset !important; }

    /* Tablas: scroll horizontal */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 600px; }

    /* Modales: pantalla completa */
    .modal-card {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    .modal-card-lg { width: 100vw !important; }

    /* Controles de vista */
    .view-controls {
        flex-wrap: wrap;
        gap: 8px;
    }
    .search-box { width: 100%; }

    /* Gráfico: altura reducida en móvil */
    .chart-container { height: 220px; }

    /* Calendario: texto más pequeño */
    .cal-cell { min-height: 50px; padding: 4px; }
    .cal-day-num { font-size: 0.72rem; }

    /* Historial de cliente: KPIs en 2 columnas */
    .client-history-kpis { gap: 0.5rem; }
    .ch-kpi { min-width: calc(50% - 0.5rem); }

    /* Notificaciones: panel más amplio */
    .notif-panel { width: calc(100vw - 2rem); right: 1rem; }
}

/* Botón hamburguesa (oculto en desktop) */
#btn-mobile-menu { display: none; }

/* ============================================================
   SIDEBAR — SUBMENÚ COLAPSABLE
   ============================================================ */
.nav-sub {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}
.nav-sub.hidden {
    display: none;
}
.nav-sub-item {
    padding-left: 2.4rem !important;
    font-size: 0.82rem !important;
    opacity: 0.85;
    position: relative;
}
.nav-sub-item::before {
    content: '';
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--text-2);
    opacity: 0.5;
}
.nav-sub-item.active::before {
    background: var(--accent);
    opacity: 1;
}
.nav-sub-item:hover::before { opacity: 0.8; }

.nav-group-toggle {
    cursor: pointer;
    user-select: none;
}
.nav-group-toggle .nav-chevron {
    flex-shrink: 0;
    opacity: 0.6;
}
.nav-group-toggle:hover .nav-chevron { opacity: 1; }
