:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --border: #e4e9ef;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #1f4f8a;
    --primary-dark: #173b67;
    --sidebar: #17202b;
    --sidebar-hover: #212d3b;
    --sidebar-active: #2a3a4b;
    --success-bg: #eaf8ef;
    --success-text: #247443;
    --warning-bg: #fff5dc;
    --warning-text: #9a6c00;
    --danger-bg: #fdecec;
    --danger-text: #b33c3c;
    --shadow: 0 8px 24px rgba(20, 30, 45, 0.08);
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(31, 79, 138, .12), transparent 36%),
        linear-gradient(135deg, #eef3f8, #f7f8fa);
}

.login-wrapper {
    width: 100%;
    max-width: 430px;
}

.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 34px;
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.brand-logo {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--primary);
    color: white;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: .4px;
}

.brand-logo.small {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 14px;
}

.login-brand h1,
.page-header h1,
.section-title-row h2,
.modal-header h2,
.welcome-panel h2 {
    margin: 0;
}

.login-brand p,
.page-header p,
.section-title-row p,
.modal-header p,
.welcome-panel p {
    margin: 4px 0 0;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    border: 1px solid #d4dbe4;
    border-radius: 9px;
    padding: 11px 12px;
    outline: none;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 79, 138, .10);
}

.password-box {
    position: relative;
}

.password-box input {
    padding-right: 78px;
}

.password-toggle {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--primary);
    font-weight: 600;
}

.btn {
    border: 0;
    border-radius: 9px;
    padding: 10px 16px;
    font-weight: 600;
    transition: transform .12s, background .15s;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #eef2f6;
    color: #344054;
}

.btn-secondary:hover {
    background: #e4e9ef;
}

.btn-block {
    width: 100%;
}

.btn-small {
    padding: 7px 10px;
    font-size: 13px;
}

.btn-icon {
    border: 0;
    background: transparent;
    color: #a33a3a;
    font-size: 22px;
    line-height: 1;
}

.alert {
    padding: 11px 13px;
    border-radius: 9px;
    margin-bottom: 18px;
    font-size: 14px;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.login-note {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.app-body {
    min-height: 100vh;
    background: var(--bg);
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    position: fixed;
    top: 0;
    left: 240px;
    right: 0;
    height: 68px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 26px;
    z-index: 20;
}

.topbar-left,
.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title {
    font-weight: 700;
}

.menu-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #e7eef7;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-weight: 800;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.user-info strong {
    font-size: 14px;
}

.user-info small {
    color: var(--muted);
    margin-top: 3px;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    background: var(--sidebar);
    color: #dbe4ee;
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.sidebar-brand {
    height: 68px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.sidebar-brand > div:last-child {
    display: flex;
    flex-direction: column;
}

.sidebar-brand span {
    color: #8fa1b4;
    font-size: 12px;
    margin-top: 2px;
}

.sidebar-nav {
    padding: 16px 10px;
    display: grid;
    gap: 4px;
}

.nav-item {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 13px;
    border-radius: 9px;
    color: #cbd6e2;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: white;
    box-shadow: inset 3px 0 0 #6fa7e5;
}

.nav-icon {
    width: 22px;
    text-align: center;
    font-size: 18px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, .07);
}

.nav-logout {
    color: #f0caca;
}

.main-content {
    margin-left: 240px;
    padding: 96px 28px 30px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 22px;
}

.page-header h1 {
    font-size: 26px;
}

.page-header p {
    font-size: 14px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.module-card,
.content-card,
.welcome-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 3px 14px rgba(20, 30, 45, .04);
}

.module-card {
    min-height: 150px;
    padding: 20px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 15px;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.module-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: #cbd5e1;
}

.module-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #edf3fa;
    color: var(--primary);
    font-weight: 800;
}

.module-info h2 {
    margin: 0 0 7px;
    font-size: 17px;
}

.module-info p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.module-arrow {
    font-size: 22px;
    color: #9aa5b1;
}

.welcome-panel {
    padding: 26px;
}

.eyebrow {
    display: inline-block;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 8px;
}

.content-card {
    padding: 20px;
    margin-bottom: 18px;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 18px;
}

.section-title-row h2 {
    font-size: 18px;
}

.search-row {
    display: flex;
    align-items: end;
    gap: 12px;
}

.grow {
    flex: 1;
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    color: #576474;
    background: #f8fafc;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .35px;
}

.data-table th,
.data-table td {
    padding: 12px 11px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: #fafcff;
}

.text-right {
    text-align: right !important;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.order-footer {
    display: flex;
    justify-content: flex-end;
    align-items: end;
    gap: 24px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.order-total {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.order-total span {
    color: var(--muted);
    font-size: 13px;
}

.order-total strong {
    font-size: 22px;
    margin-top: 3px;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .48);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal.show {
    display: flex;
}

.modal-dialog {
    width: 100%;
    max-width: 650px;
    background: white;
    border-radius: 14px;
    box-shadow: 0 20px 55px rgba(0, 0, 0, .22);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    border: 0;
    background: transparent;
    font-size: 26px;
    color: #7a8491;
}

.modal-body {
    padding: 22px;
}

.detail-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.detail-summary > div {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
}

.detail-summary span {
    font-size: 12px;
    color: var(--muted);
}

.detail-summary strong {
    margin-top: 5px;
}

.movement-list {
    display: grid;
    gap: 10px;
}

.movement-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 12px 14px;
}

.movement-item > div {
    display: flex;
    flex-direction: column;
}

.movement-item span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 1050px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .topbar {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 90px 16px 22px;
    }

    .menu-toggle {
        display: block;
    }

    .sidebar-overlay.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .4);
        z-index: 25;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .full {
        grid-column: auto;
    }
}

@media (max-width: 640px) {
    .login-card {
        padding: 25px 20px;
    }

    .search-row,
    .section-title-row,
    .order-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .detail-summary {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 0 14px;
    }

    .user-info {
        display: none;
    }

    .content-card {
        padding: 15px;
    }
}

.hidden{display:none!important}.client-search{position:relative;max-width:760px}.search-results{display:none;position:absolute;left:0;right:0;top:calc(100% + 5px);z-index:50;background:#fff;border:1px solid var(--border);border-radius:10px;box-shadow:var(--shadow);max-height:330px;overflow-y:auto}.search-results.show{display:block}.client-result{width:100%;border:0;border-bottom:1px solid var(--border);background:#fff;padding:12px 14px;text-align:left;display:flex;flex-direction:column;gap:4px}.client-result:hover{background:#f7f9fc}.client-result span{color:var(--muted);font-size:13px}.search-message,.empty-table{padding:18px!important;text-align:center!important;color:var(--muted)}.error-text{color:var(--danger-text)!important}.client-card{background:var(--panel);border:1px solid var(--border);border-radius:var(--radius);padding:20px;margin-bottom:18px;display:flex;justify-content:space-between;align-items:center;gap:18px}.client-card h2{margin:2px 0 10px}.client-meta{display:flex;flex-wrap:wrap;gap:8px 22px;color:var(--muted);font-size:13px}.client-meta strong{color:var(--text)}.modal-large{max-width:1050px;max-height:92vh;overflow-y:auto}.modal-large .detail-summary{grid-template-columns:repeat(6,1fr)}.loading-state{padding:36px;text-align:center;color:var(--muted)}.section-spacer{margin-top:28px}.movement-columns{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}.movement-columns h4{margin:0 0 9px}.movement-empty{border:1px dashed var(--border);border-radius:9px;padding:16px;text-align:center;color:var(--muted);font-size:13px}@media(max-width:1000px){.modal-large .detail-summary{grid-template-columns:repeat(3,1fr)}.movement-columns{grid-template-columns:1fr}}@media(max-width:640px){.client-card{flex-direction:column;align-items:stretch}.modal-large .detail-summary{grid-template-columns:1fr 1fr}}

.table-toolbar{display:flex;justify-content:space-between;align-items:flex-end;gap:18px;padding:14px 0 18px;border-top:1px solid var(--border)}
.table-toolbar-left{display:flex;align-items:flex-end;gap:12px}
.toolbar-field{display:flex;flex-direction:column;gap:6px}
.toolbar-field label{font-size:12px;font-weight:700;color:var(--muted)}
.toolbar-field select,.toolbar-field input{height:39px;border:1px solid #d4dbe4;border-radius:8px;background:#fff;padding:0 11px;outline:none;color:var(--text)}
.toolbar-field select:focus,.toolbar-field input:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(31,79,138,.10)}
.compact-field select{min-width:82px}
.search-invoices{width:min(100%,360px)}
.search-invoices input{width:100%}
.table-pagination{display:flex;align-items:center;justify-content:space-between;gap:16px;padding-top:18px}
.pagination-info{font-size:13px;color:var(--muted)}
.pagination-buttons{display:flex;align-items:center;gap:5px}
.page-btn{min-width:35px;height:35px;padding:0 9px;border:1px solid var(--border);border-radius:7px;background:#fff;color:var(--text);font-weight:600}
.page-btn:hover:not(:disabled){border-color:#b8c5d3;background:#f6f8fa}
.page-btn.active{background:var(--primary);border-color:var(--primary);color:#fff}
.page-btn:disabled{opacity:.4;cursor:default}
.page-dots{padding:0 4px;color:var(--muted)}
@media(max-width:700px){
 .table-toolbar{flex-direction:column;align-items:stretch}
 .table-toolbar-left{width:100%}
 .table-toolbar-left .toolbar-field{flex:1}
 .search-invoices{width:100%}
 .table-pagination{flex-direction:column;align-items:flex-start}
 .pagination-buttons{flex-wrap:wrap}
}

.inventory-search-row{display:flex;align-items:flex-end;gap:12px}.inventory-table .inventory-description{min-width:250px;white-space:normal}.stock-ok,.stock-empty{display:inline-block;min-width:62px;padding:4px 7px;border-radius:7px;font-weight:700}.stock-ok{background:var(--success-bg);color:var(--success-text)}.stock-empty{background:var(--danger-bg);color:var(--danger-text)}@media(max-width:640px){.inventory-search-row{flex-direction:column;align-items:stretch}}

/* ===== Detalle de producto ===== */
.inventory-row{cursor:pointer}
.inventory-row:hover{background:#f7f9fc}
.product-link{border:0;background:none;padding:0;color:var(--primary);font:inherit;font-weight:700;text-align:left;cursor:pointer}
.product-modal-dialog{max-width:1100px}
.product-detail-grid{display:grid;grid-template-columns:minmax(280px,380px) 1fr;gap:30px}
.product-gallery{min-width:0}
.product-main-image{height:350px;border:1px solid var(--border);border-radius:12px;background:#f8fafc;display:flex;align-items:center;justify-content:center;overflow:hidden}
.product-main-image img{width:100%;height:100%;object-fit:contain}
.product-no-image{color:var(--muted);font-weight:600}
.product-thumbnails{display:flex;gap:8px;overflow-x:auto;padding-top:10px}
.product-thumb{width:66px;height:66px;flex:0 0 66px;padding:3px;border:1px solid var(--border);border-radius:8px;background:#fff;cursor:pointer}
.product-thumb.active{border:2px solid var(--primary)}
.product-thumb img{width:100%;height:100%;object-fit:cover;border-radius:5px}
.product-information h2{margin:0 0 18px;font-size:24px}
.product-data-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.product-data-grid>div,.product-stock-grid>div{padding:12px;border:1px solid var(--border);border-radius:9px;background:#fff}
.product-data-grid span,.product-stock-grid span,.product-price-box span{display:block;color:var(--muted);font-size:12px;margin-bottom:4px}
.product-data-grid strong,.product-stock-grid strong{font-size:14px}
.product-stock-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:16px}
.product-stock-grid strong{font-size:18px}
.product-price-box{margin-top:16px;padding:16px 18px;border-radius:10px;background:#f5f8fc;border:1px solid var(--border)}
.product-price-box strong{display:block;font-size:27px;color:var(--primary)}
.product-price-box small{display:block;margin-top:4px;color:var(--muted)}
.product-tech-sheet{margin-top:28px;padding-top:22px;border-top:1px solid var(--border)}
.product-tech-sheet h3{margin:0 0 12px}
.product-synopsis{white-space:pre-wrap;line-height:1.65;color:var(--text)}
@media(max-width:800px){
 .product-detail-grid{grid-template-columns:1fr}
 .product-main-image{height:300px}
}
@media(max-width:520px){
 .product-data-grid{grid-template-columns:1fr}
 .product-stock-grid{grid-template-columns:1fr}
}

/* ===== Crear proforma ===== */
.product-search-list{margin-top:16px;display:flex;flex-direction:column;gap:8px}.pf-product{display:grid;grid-template-columns:minmax(240px,1fr) 100px 135px 90px auto;align-items:center;gap:14px;padding:12px 14px;border:1px solid var(--border);border-radius:10px;background:#fff}.pf-product-main{display:flex;flex-direction:column;gap:4px}.pf-product-main span,.pf-product-stock span,.pf-product-price span{font-size:12px;color:var(--muted)}.pf-product-stock,.pf-product-price{display:flex;flex-direction:column}.pf-qty{height:39px;width:90px;border:1px solid var(--border);border-radius:8px;padding:0 8px;text-align:right}.proforma-bottom{display:grid;grid-template-columns:1fr 330px;gap:30px;margin-top:24px;align-items:start}.proforma-observaciones textarea{width:100%}.proforma-totals{border:1px solid var(--border);border-radius:12px;padding:18px;background:#f8fafc}.proforma-totals>div{display:flex;justify-content:space-between;gap:20px;padding:7px 0}.proforma-totals .grand-total{margin-top:7px;padding-top:14px;border-top:1px solid var(--border);font-size:20px}.proforma-totals .grand-total strong{color:var(--primary)}.proforma-totals .btn{margin-top:14px}@media(max-width:900px){.pf-product{grid-template-columns:1fr 100px 120px}.pf-product .pf-qty,.pf-product .pf-add{grid-row:2}.proforma-bottom{grid-template-columns:1fr}}@media(max-width:600px){.pf-product{grid-template-columns:1fr 1fr}.pf-product-main{grid-column:1/-1}.pf-product .pf-add{width:100%}}

/* ===== Proforma: paginación, negativos y toast ===== */
.pf-products-pagination{padding-top:12px}.stock-negative{color:var(--danger-text)}
.app-toast{position:fixed;right:24px;bottom:24px;z-index:200;max-width:420px;padding:14px 18px;border-radius:10px;background:#17365d;color:#fff;font-weight:600;box-shadow:0 12px 32px rgba(15,23,42,.25);opacity:0;transform:translateY(14px);pointer-events:none;transition:opacity .2s ease,transform .2s ease}.app-toast.show{opacity:1;transform:translateY(0)}
@media(max-width:640px){.app-toast{left:14px;right:14px;bottom:14px;max-width:none}}

.pf-product .pf-info{white-space:nowrap}
@media(max-width:900px){.pf-product{flex-wrap:wrap}.pf-product-main{min-width:240px;flex:1 1 100%}}

/* ===== Catálogo visual compartido: Inventario / Proforma ===== */
.catalog-product-list,.product-search-list{display:flex;flex-direction:column;gap:10px}
.catalog-product-card{display:grid;grid-template-columns:120px minmax(260px,1fr) 105px 105px 105px 145px auto;align-items:center;gap:16px;padding:14px 16px;border:1px solid var(--border);border-radius:12px;background:#fff}
.catalog-product-card:hover{border-color:#c7d3e0;box-shadow:0 3px 12px rgba(15,23,42,.05)}
.catalog-thumb{width:105px;height:105px;display:flex;align-items:center;justify-content:center;border-radius:9px;background:#f8fafc;overflow:hidden}
.catalog-thumb img{display:block;max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain}
.catalog-main{display:flex;flex-direction:column;gap:5px;min-width:0}
.catalog-title{font-size:16px;font-weight:700;line-height:1.3;color:var(--text)}
.catalog-main span,.catalog-main small{font-size:12px;color:var(--muted)}
.catalog-metric{display:flex;flex-direction:column;gap:3px}
.catalog-metric span{font-size:12px;color:var(--muted)}
.catalog-metric strong{font-size:16px}
.catalog-metric small{font-size:11px;color:var(--muted)}
.stock-positive{color:#16803a}
.catalog-info{white-space:nowrap}
.inventory-row{cursor:default}
.inventory-row .product-link{cursor:pointer}
.pf-product{grid-template-columns:120px minmax(260px,1fr) 115px 145px 90px auto auto}
.pf-product .pf-add{width:auto;min-width:110px}
.pf-product .pf-info{width:auto}
@media(max-width:1100px){
 .catalog-product-card,.pf-product{grid-template-columns:95px minmax(220px,1fr) 105px 125px}
 .catalog-thumb{width:85px;height:85px}
 .inventory-row .catalog-metric:nth-of-type(3),.inventory-row .catalog-metric:nth-of-type(4){display:none}
 .catalog-info,.pf-product .pf-qty,.pf-product .pf-info,.pf-product .pf-add{grid-row:2}
 .catalog-info{grid-column:4}
 .pf-product .pf-qty{grid-column:2}
 .pf-product .pf-info{grid-column:3}
 .pf-product .pf-add{grid-column:4}
}
@media(max-width:700px){
 .catalog-product-card,.pf-product{grid-template-columns:78px 1fr;gap:10px}
 .catalog-thumb{width:70px;height:70px;grid-row:1/3}
 .catalog-main{grid-column:2}
 .catalog-metric{grid-row:auto}
 .catalog-info,.pf-product .pf-qty,.pf-product .pf-info,.pf-product .pf-add{grid-column:auto;grid-row:auto}
 .pf-product .pf-add,.pf-product .pf-info{width:100%}
}

.app-toast.toast-error{background:#b42318!important;color:#fff!important;border-color:#b42318!important;}

/* Mantener sesión abierta */
.remember-row{display:flex;align-items:center;justify-content:space-between;gap:18px;padding:4px 0 2px;cursor:pointer;color:var(--text)}
.remember-row span:first-child{display:flex;flex-direction:column;gap:2px}
.remember-row strong{font-size:13px;font-weight:600}
.remember-row small{font-size:11px;color:var(--muted)}
.switch-control{position:relative;display:inline-block;width:46px;height:26px;flex:0 0 46px}
.switch-control input{opacity:0;width:0;height:0;position:absolute}
.switch-slider{position:absolute;inset:0;border-radius:999px;background:#cbd5e1;transition:.2s}
.switch-slider:before{content:'';position:absolute;width:20px;height:20px;left:3px;top:3px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.2);transition:.2s}
.switch-control input:checked + .switch-slider{background:var(--primary)}
.switch-control input:checked + .switch-slider:before{transform:translateX(20px)}


/* ========================= CLIENTES ========================= */
.clientes-toolbar{align-items:end}.clientes-toolbar .grow{flex:1;min-width:280px}.clientes-table tbody tr.cliente-row{cursor:pointer}.clientes-table tbody tr.cliente-row:hover{background:#f7f9fc}.cliente-modal-dialog{max-width:780px}.cliente-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.cliente-form-grid .span-2{grid-column:span 2}.cliente-form-grid textarea{resize:vertical}.check-line{display:flex!important;align-items:center;gap:9px;min-height:42px;font-weight:500!important}.check-line input{width:17px;height:17px}.status-badge{display:inline-flex;align-items:center;padding:5px 9px;border-radius:999px;font-size:11px;font-weight:700}.status-success{background:#e9f8ef;color:#247a46}.status-warning{background:#fff5df;color:#9a6700}.status-danger{background:#fdecec;color:#b42318}.btn-icon{width:34px;height:34px;border:1px solid #d9e0e8;border-radius:8px;background:#fff;cursor:pointer;font-size:16px}.btn-icon:hover{background:#f2f6fa}.text-right{text-align:right}@media(max-width:700px){.cliente-form-grid{grid-template-columns:1fr}.cliente-form-grid .span-2{grid-column:span 1}.clientes-toolbar{align-items:stretch}.clientes-toolbar .grow{min-width:0}}

/* ========================= CRM KANBAN ========================= */
.crm-main{overflow-x:hidden}.crm-toolbar{display:flex;gap:16px;align-items:end;margin-bottom:18px}.crm-toolbar .grow{flex:1}.crm-board{display:flex;gap:16px;align-items:flex-start;overflow-x:auto;padding:2px 2px 18px;min-height:560px}.crm-column{flex:0 0 290px;background:#f5f7fa;border:1px solid var(--border);border-radius:13px;min-height:500px}.crm-column>header{display:flex;justify-content:space-between;align-items:center;padding:14px 15px;border-bottom:1px solid var(--border)}.crm-column>header span{background:#e5ebf2;border-radius:999px;min-width:26px;padding:3px 8px;text-align:center;font-size:12px}.crm-drop{padding:10px;min-height:445px}.crm-column.drag-over{outline:2px solid var(--primary);outline-offset:-2px}.crm-card{background:#fff;border:1px solid var(--border);border-radius:11px;padding:13px;margin-bottom:10px;cursor:pointer;box-shadow:0 2px 7px rgba(15,23,42,.035)}.crm-card:hover{border-color:#bdcad8;box-shadow:0 5px 16px rgba(15,23,42,.08)}.crm-card-top,.crm-card-foot{display:flex;justify-content:space-between;gap:10px;color:var(--muted);font-size:11px}.crm-origin{font-weight:700;color:var(--primary)}.crm-card h3{font-size:14px;margin:9px 0 6px}.crm-contact{display:block;font-size:13px}.crm-card>small{display:block;color:var(--muted);margin-top:2px}.crm-card-money{font-size:17px;font-weight:800;margin:13px 0}.crm-card-foot{border-top:1px solid #edf1f5;padding-top:9px;flex-direction:column}.crm-modal-dialog{max-width:820px}.crm-detail-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;padding-bottom:20px;border-bottom:1px solid var(--border)}.crm-detail-grid>div{display:flex;flex-direction:column;gap:4px}.crm-detail-grid label{font-size:11px;color:var(--muted);text-transform:uppercase;font-weight:700}.crm-detail-grid small{color:var(--muted)}.crm-detail-grid .span-2{grid-column:span 2}.crm-detail-grid p{margin:0;white-space:pre-wrap}.crm-reassign{display:flex;gap:10px}.crm-reassign select{flex:1}.crm-activity{margin-top:22px}.crm-activity h3{margin-bottom:12px}.crm-activity form{display:grid;grid-template-columns:140px 1fr auto;gap:8px}.crm-timeline{margin-top:18px}.crm-activity-row{display:grid;grid-template-columns:100px 1fr;gap:12px;padding:12px 0;border-bottom:1px solid #edf1f5}.crm-activity-row>span{font-size:11px;font-weight:700;color:var(--primary)}.crm-activity-row p{margin:4px 0}.crm-activity-row small{color:var(--muted)}@media(max-width:700px){.crm-toolbar{flex-direction:column;align-items:stretch}.crm-detail-grid{grid-template-columns:1fr}.crm-detail-grid .span-2{grid-column:span 1}.crm-activity form{grid-template-columns:1fr}.crm-column{flex-basis:270px}}

.crm-client-badge,.crm-prospect-badge{display:inline-block;width:max-content;margin-top:7px;padding:4px 8px;border-radius:999px;font-size:11px;font-weight:700}
.crm-client-badge{background:#e8f5ee;color:#237a4b}
.crm-prospect-badge{background:#fff3df;color:#9a6500}

.crm-commerce{margin-top:22px;padding-top:20px;border-top:1px solid var(--border)}
.crm-commerce .section-title-row{margin-bottom:14px}
.crm-commerce .catalog-product-card{grid-template-columns:72px minmax(180px,1fr) 90px 110px 78px auto auto}
.crm-cart{margin-top:24px;padding-top:20px;border-top:1px solid var(--border)}
.crm-commerce-locked{margin-top:20px;padding:15px 17px;border:1px dashed var(--border);border-radius:11px;background:#f8fafc}
.crm-commerce-locked p{margin:4px 0 0;color:var(--muted)}
@media(max-width:900px){.crm-commerce .catalog-product-card{grid-template-columns:64px 1fr}.crm-commerce .catalog-metric,.crm-commerce .crm-qty,.crm-commerce .btn{grid-column:auto}}

/* CRM Fase 4 */
.crm-modal-dialog{max-width:1180px}
.crm-commerce .catalog-product-card{grid-template-columns:78px minmax(250px,1fr) 92px 115px 86px 132px 92px;gap:12px}
.crm-commerce .catalog-thumb{width:78px;height:78px}
.crm-commerce .crm-qty{width:86px;min-width:0}
.crm-commerce .btn{white-space:normal}
.crm-status-filter{min-width:150px}
.crm-linked-proforma{display:flex;justify-content:space-between;gap:15px;align-items:center;margin:14px 0 20px;padding:13px 15px;border:1px solid var(--border);border-radius:10px;background:#f8fafc}
.modal-footer{padding-left:10px!important;padding-right:10px!important;padding-bottom:10px!important}
@media(max-width:1050px){.crm-commerce .catalog-product-card{grid-template-columns:72px minmax(220px,1fr) 90px 110px}.crm-commerce .crm-qty,.crm-commerce .btn{width:100%}}

.crm-proforma-created{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin-top:10px}
.crm-proforma-created>div{padding:14px 16px;border:1px solid var(--border);border-radius:10px;background:#f8fafc}
.crm-proforma-created span{display:block;font-size:12px;color:var(--muted);margin-bottom:5px}
.crm-proforma-created strong{font-size:16px}
.crm-proforma-note{margin:12px 0 0;color:var(--muted)}
@media(max-width:760px){.crm-proforma-created{grid-template-columns:1fr}}

/* CRM Fase 6 */
.crm-card-locked{cursor:pointer}
.crm-proforma-lines{margin-top:16px}
.crm-proforma-lines .data-table{min-width:760px}

/* CRM Fase 7 - Conversaciones */
.crm-conversation{margin-top:22px;padding-top:18px;border-top:1px solid var(--border)}
.crm-channel-badge{display:inline-flex;margin:6px 0 12px;padding:6px 10px;border:1px solid var(--border);border-radius:999px;background:#f8fafc;font-size:12px}
.crm-message-list{display:flex;flex-direction:column;gap:8px;max-height:300px;overflow:auto;padding:10px 0}
.crm-message{max-width:78%;padding:9px 11px;border:1px solid var(--border);border-radius:10px;background:#fff}
.crm-message.out{align-self:flex-end;background:#f8fafc}
.crm-message.in{align-self:flex-start}
.crm-message small{display:block;margin-top:4px;color:var(--muted);font-size:11px}
.crm-conversation-note{margin:10px 0 0;color:var(--muted);font-size:12px}

/* CRM Fase 8 - WhatsApp Meta */
.crm-message-compose{display:flex;gap:10px;align-items:flex-end;margin-top:10px}
.crm-message-compose textarea{flex:1;resize:vertical;min-height:58px}
.crm-message-compose .btn{min-width:95px}

/* CRM Fase 10 - Configuración Meta */
.crm-meta-info{margin-top:18px}
.crm-copy-row,.password-inline{display:flex;gap:10px;align-items:center}
.crm-copy-row input,.password-inline input{flex:1}
.form-help{margin-top:8px;color:var(--muted)}
.status-pill.muted{background:#f1f5f9;color:#64748b}


/* CRM Fase 9 - Conversación omnicanal */
.crm-channel-whatsapp .crm-channel-badge{background:#eafaf1;border-color:#b7e4c7;color:#176b3a}
.crm-channel-whatsapp .crm-channel-icon{color:#25d366;font-size:18px;line-height:1}
.crm-channel-whatsapp .crm-message.out{background:#dcf8c6;border-color:#c5e8ae}
.crm-channel-whatsapp .crm-message.in{background:#fff}
.crm-message-list{max-height:320px;overflow-y:auto;padding:12px;background:#f7f8f7;border:1px solid var(--border);border-radius:10px}
.crm-message-agent{display:block;margin-bottom:3px;font-size:11px;font-weight:700;color:#176b3a}
.crm-conversation-tools{display:flex;flex-wrap:wrap;gap:7px;margin-top:10px;padding:8px;border:1px solid var(--border);border-radius:9px;background:#fff}
.crm-tool-btn{border:1px solid var(--border);background:#fff;border-radius:7px;padding:7px 10px;cursor:pointer;font-size:12px}
.crm-tool-btn:disabled{opacity:.48;cursor:not-allowed}
.crm-doc-menu{position:relative}.crm-doc-dropdown{display:none;position:absolute;left:0;bottom:100%;min-width:175px;padding:5px;background:#fff;border:1px solid var(--border);border-radius:8px;box-shadow:0 8px 24px rgba(15,23,42,.12);z-index:20}
.crm-doc-dropdown.show{display:block}.crm-doc-dropdown button{display:block;width:100%;text-align:left;border:0;background:#fff;padding:8px;border-radius:5px}.crm-doc-dropdown button:disabled{color:var(--muted)}
.crm-whatsapp-send{background:#128c7e;border-color:#128c7e}
@media(max-width:760px){.crm-message{max-width:90%}.crm-message-compose{align-items:stretch;flex-direction:column}.crm-message-compose .btn{width:100%}}

/* CRM Fase 9.1 - Alertas y tiempos de atención */
.crm-card-signals{display:flex;align-items:center;gap:7px}
.crm-new-message{display:inline-flex;width:18px;height:18px;align-items:center;justify-content:center;border-radius:50%;background:#25d366;color:#fff;font-size:10px;box-shadow:0 0 0 3px rgba(37,211,102,.14)}
.crm-card-new-message{border-color:#25d366;box-shadow:0 0 0 2px rgba(37,211,102,.13),0 5px 16px rgba(15,23,42,.08)}
.crm-open-time{display:inline-flex;align-items:center;gap:4px;margin:-4px 0 10px;font-size:11px;font-weight:700;color:#64748b}

/* CRM Fase 9.2 - mensajeria en vivo y canal */
.crm-origin{display:inline-flex;align-items:center;gap:5px}
.crm-origin .crm-whatsapp-svg{width:15px;height:15px;color:#25d366;flex:0 0 15px}
.crm-channel-badge{align-items:center;gap:7px}
.crm-whatsapp-svg{width:19px;height:19px;color:#25d366;flex:0 0 19px}
.crm-channel-letter{display:inline-flex;align-items:center;justify-content:center;width:19px;height:19px;font-weight:800}
.crm-message small{display:flex;align-items:center;justify-content:flex-end;gap:5px}
.crm-message.in small{justify-content:flex-start}
.crm-msg-state{display:inline-flex;align-items:center}
.crm-msg-check{font-size:13px;font-weight:800;letter-spacing:-3px;padding-right:3px;color:#667085}
.crm-msg-check.read{color:#34b7f1}
.crm-msg-check.sending{letter-spacing:0;color:#98a2b3}
.crm-msg-check.error{letter-spacing:0;color:#d92d20}
.crm-message-pending{opacity:.72}
.crm-message-error{border-color:#f1aeb5!important}
.crm-wa-window{margin:8px 0 10px;padding:8px 12px;border-radius:8px;font-size:13px;font-weight:600}.crm-wa-window.open{background:#e9f8ef;color:#16723a}.crm-wa-window.closed{background:#fff3e6;color:#9a5700}.crm-quick-box{display:none;max-height:220px;overflow:auto;border:1px solid #dfe5e8;border-radius:10px;background:#fff;margin:6px 0;box-shadow:0 8px 24px rgba(0,0,0,.08)}.crm-quick-box.show{display:block}.crm-quick-item{width:100%;display:grid;grid-template-columns:100px 1fr auto;gap:10px;align-items:center;border:0;border-bottom:1px solid #eef1f3;background:#fff;padding:9px 12px;text-align:left;cursor:pointer}.crm-quick-item:hover{background:#f4fbf7}.crm-quick-item strong{color:#16854b}.crm-quick-item small{color:#7a858c}.crm-template-send{padding:12px;border:1px solid #e4e8eb;border-radius:10px;background:#fafbfc}.crm-template-row{display:flex;gap:10px;margin-top:10px}.crm-template-row select{flex:1}.crm-template-preview{margin-top:10px;padding:10px;border-radius:8px;background:#fff}.crm-template-preview p{white-space:pre-wrap;margin:6px 0 0}.config-actions{display:flex;justify-content:flex-end;margin-top:12px}

/* CRM Fase 9.4 - Cola y colaboración */
.crm-send-error{margin-top:6px;padding-top:5px;border-top:1px solid rgba(217,45,32,.18);font-size:11px;color:#b42318}.crm-retry-msg{border:0;background:transparent;color:#b42318;font-weight:700;cursor:pointer}.crm-note-btn{background:#fff8db;border-color:#f1d97a}.crm-note-compose{display:flex;gap:8px;margin-top:8px;padding:9px;background:#fff8db;border:1px solid #f1d97a;border-radius:9px}.crm-note-compose textarea{flex:1}.crm-internal-note{align-self:center;width:min(88%,650px);padding:9px 12px;border:1px solid #f1d97a;border-radius:9px;background:#fff8db;color:#604b00}.crm-internal-note strong{display:block;font-size:11px;margin-bottom:3px}.crm-internal-note small{display:block;margin-top:4px;color:#8a741f;font-size:11px}.crm-chat-badge{display:inline-flex;min-width:18px;height:18px;padding:0 5px;align-items:center;justify-content:center;border-radius:10px;background:#d92d20;color:#fff;font-size:10px}.crm-internal-chat{display:grid;grid-template-columns:240px 1fr;min-height:420px;border:1px solid var(--border);border-radius:10px;overflow:hidden}.crm-chat-users{border-right:1px solid var(--border);overflow:auto}.crm-chat-user{width:100%;display:flex;justify-content:space-between;gap:8px;padding:11px;border:0;border-bottom:1px solid var(--border);background:#fff;text-align:left;cursor:pointer}.crm-chat-user.active,.crm-chat-user:hover{background:#f4f7f9}.crm-chat-user b{display:inline-flex;min-width:20px;height:20px;align-items:center;justify-content:center;border-radius:10px;background:#25d366;color:#fff;font-size:10px}.crm-chat-pane{display:flex;flex-direction:column;min-width:0}.crm-chat-title{padding:11px 14px;border-bottom:1px solid var(--border);font-weight:700}.crm-chat-messages{flex:1;max-height:390px;overflow:auto;padding:12px;background:#f7f8f9;display:flex;flex-direction:column;gap:7px}.crm-chat-msg{max-width:75%;padding:8px 10px;border:1px solid var(--border);border-radius:9px;background:#fff}.crm-chat-msg.out{align-self:flex-end;background:#e9f8ef}.crm-chat-msg.in{align-self:flex-start}.crm-chat-msg small{display:block;margin-top:3px;color:var(--muted);font-size:10px}.crm-chat-compose{display:flex;gap:8px;padding:10px;border-top:1px solid var(--border)}.crm-chat-compose textarea{flex:1}.hidden{display:none!important}@media(max-width:760px){.crm-internal-chat{grid-template-columns:1fr}.crm-chat-users{max-height:150px;border-right:0;border-bottom:1px solid var(--border)}}

/* CRM Fase 9.4.1 - menciones */
.crm-note-editor{position:relative;flex:1}.crm-note-editor textarea{width:100%;box-sizing:border-box}
.crm-mention-suggestions{position:absolute;left:0;right:0;bottom:calc(100% + 4px);z-index:20;max-height:230px;overflow:auto;background:#fff;border:1px solid var(--border);border-radius:9px;box-shadow:0 8px 24px rgba(0,0,0,.12)}
.crm-mention-suggestions button{width:100%;display:flex;align-items:center;justify-content:space-between;gap:10px;border:0;border-bottom:1px solid var(--border);background:#fff;padding:9px 11px;text-align:left;cursor:pointer}
.crm-mention-suggestions button:last-child{border-bottom:0}.crm-mention-suggestions button:hover{background:#f4f7f9}.crm-mention-suggestions small{color:var(--muted)}
.crm-mentions-list{display:flex;flex-direction:column;gap:8px}.crm-mention-item{width:100%;border:1px solid var(--border);border-radius:9px;background:#fff;padding:10px 12px;text-align:left;cursor:pointer}
.crm-mention-item:hover{background:#fff8db;border-color:#f1d97a}.crm-mention-item>div{display:flex;justify-content:space-between;gap:12px}.crm-mention-item span,.crm-mention-item small{color:var(--muted);font-size:11px}.crm-mention-item p{margin:6px 0;white-space:pre-wrap}

/* CRM Fase 9.4.2 - acceso por mención */
.crm-mention-access-banner,.crm-mention-readonly{
  border:1px solid #ead58b;background:#fff8dc;border-radius:9px;
  padding:10px 12px;margin-bottom:12px;color:#5f4a00
}
.crm-mention-readonly{margin-top:10px}

/* CRM Fase 9.4.4 - agentes por cola */
.crm-queue-config{max-width:900px}.crm-queue-config>.form-group{max-width:360px;margin-bottom:14px}
.crm-queue-config input[type=checkbox]{width:18px;height:18px;cursor:pointer}
.crm-queue-config .data-table td{vertical-align:middle}

/* Fase 9.4.5 */
#crmColasTabla td{vertical-align:middle}#crmColaModal .modal-dialog{max-width:720px}

/* CRM Fase 10.1 */
.crm-product-wa-dialog{max-width:850px}.crm-product-wa-search{display:flex;gap:8px;margin-bottom:14px}.crm-product-wa-search input{flex:1}.crm-product-wa-results{max-height:480px;overflow:auto;border:1px solid var(--border);border-radius:10px}.crm-product-wa-card{display:grid;grid-template-columns:64px 1fr 130px 90px;gap:12px;align-items:center;padding:10px 12px;border-bottom:1px solid var(--border)}.crm-product-wa-card:last-child{border-bottom:0}.crm-product-wa-card img{width:58px;height:58px;object-fit:contain;border-radius:8px;background:#fff}.crm-product-wa-card strong,.crm-product-wa-card span,.crm-product-wa-card small{display:block}.crm-product-wa-card span,.crm-product-wa-card small{color:var(--muted);margin-top:3px}.crm-product-wa-price{text-align:right;font-weight:800}@media(max-width:760px){.crm-product-wa-card{grid-template-columns:52px 1fr}.crm-product-wa-price{text-align:left}.crm-product-wa-card .btn{grid-column:2}.crm-product-wa-search{flex-direction:column}}

/* Fase 10.1.1 */
.crm-product-wa-card{grid-template-columns:64px 1fr 125px 125px 90px}
.crm-wa-window{font-variant-numeric:tabular-nums}
@media(max-width:900px){.crm-product-wa-card{grid-template-columns:58px 1fr 110px}.crm-product-wa-card .crm-product-wa-info,.crm-product-wa-card .crm-product-wa-send{grid-column:auto}}
@media(max-width:650px){.crm-product-wa-card{grid-template-columns:52px 1fr}.crm-product-wa-price,.crm-product-wa-card .crm-product-wa-info,.crm-product-wa-card .crm-product-wa-send{grid-column:2;text-align:left}}

/* CRM Fase 10.3 */
.crm-payment-create{display:flex;align-items:center;justify-content:center;gap:9px;padding:10px 0 12px;font-size:13px;font-weight:700}
.crm-pay-label{color:var(--muted)}.crm-pay-label.active{color:var(--text)}
.crm-sales-filters{display:flex;align-items:end;gap:10px;margin-bottom:16px}.crm-sales-filters .form-group{margin-bottom:0}
@media(max-width:760px){.crm-sales-filters{align-items:stretch;flex-direction:column}.crm-sales-filters .form-group{width:100%}}
