/* ========================================
   ALUMARQ COTIZADOR - Styles
   Colors: Navy Blue (#003366) + White
   ======================================== */

:root {
    --navy: #003366;
    --navy-dark: #002244;
    --navy-light: #004488;
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #e9ecef;
    --gray-200: #dee2e6;
    --gray-300: #ced4da;
    --gray-400: #adb5bd;
    --gray-500: #6c757d;
    --gray-700: #495057;
    --gray-900: #212529;
    --danger: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
    --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-900);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ===== LOGIN SCREEN ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy-light) 100%);
}

.login-card {
    background: var(--white);
    border-radius: 12px;
    padding: 40px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background: var(--navy);
    color: var(--white);
    font-size: 32px;
    font-weight: 700;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.login-logo h1 {
    color: var(--navy);
    font-size: 28px;
    letter-spacing: 3px;
}

.login-subtitle {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

.setup-msg {
    color: var(--navy);
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
    font-weight: 500;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 16px;
    flex: 1;
    min-width: 180px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
}

.form-group-btn {
    display: flex;
    align-items: flex-end;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
    text-align: center;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-secondary {
    background: var(--gray-500);
    color: var(--white);
}
.btn-secondary:hover { background: var(--gray-700); }

.btn-outline {
    background: transparent;
    color: var(--navy);
    border: 1px solid var(--navy);
}
.btn-outline:hover { background: var(--navy); color: var(--white); }

.btn-danger {
    background: var(--danger);
    color: var(--white);
}
.btn-danger:hover { background: #c82333; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ===== APP HEADER ===== */
.app-header {
    background: var(--navy);
    color: var(--white);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 40px;
    height: 40px;
    background: var(--white);
    color: var(--navy);
    font-size: 22px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-info h1 {
    font-size: 20px;
    letter-spacing: 2px;
}

.header-tagline {
    font-size: 11px;
    opacity: 0.8;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-admin { background: var(--warning); color: var(--gray-900); }
.badge-ventas { background: var(--success); color: var(--white); }
.badge-compras { background: var(--navy-light); color: var(--white); }

#btn-logout {
    color: var(--white);
    border-color: rgba(255,255,255,0.4);
}
#btn-logout:hover {
    background: rgba(255,255,255,0.15);
    color: var(--white);
}

/* ===== NAVIGATION ===== */
.app-nav {
    background: var(--white);
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    padding: 0 24px;
    overflow-x: auto;
}

.nav-tab {
    padding: 14px 24px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-family: var(--font);
    white-space: nowrap;
    transition: all 0.2s;
}

.nav-tab:hover { color: var(--navy); }
.nav-tab.active {
    color: var(--navy);
    border-bottom-color: var(--navy);
    font-weight: 600;
}

/* ===== MAIN CONTENT ===== */
.app-content {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.panel {
    background: var(--white);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel-title {
    font-size: 18px;
    color: var(--navy);
    margin-bottom: 16px;
}

.panel-header .panel-title { margin-bottom: 0; }

/* ===== PARTIDAS ===== */
.partida {
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--gray-50);
}

.partida-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.partida-num {
    font-weight: 700;
    color: var(--navy);
    font-size: 15px;
}

.partida-resultado {
    margin-top: 12px;
    padding: 12px;
    background: var(--white);
    border-radius: 6px;
    border: 1px solid var(--gray-200);
}

.resultado-resumen {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.resultado-desc {
    font-size: 13px;
    color: var(--gray-700);
    flex: 2;
}

.resultado-unitario {
    font-size: 14px;
    color: var(--gray-500);
    flex: 1;
    text-align: right;
}

.resultado-importe {
    font-size: 16px;
    font-weight: 700;
    color: var(--navy);
    flex: 1;
    text-align: right;
}

/* ===== DIAGRAMA SVG POR PARTIDA ===== */
.resultado-diagrama {
    text-align: center;
    margin: 12px 0;
    padding: 8px;
    background: var(--gray-50);
    border-radius: 6px;
}

.resultado-diagrama:empty {
    display: none;
}

.resultado-diagrama svg {
    max-width: 100%;
    height: auto;
    max-height: 260px;
}

/* ===== RESUMEN DUAL (Optimizacion vs Compra Real) ===== */
.resumen-dual-selector {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.resumen-metodo-card {
    flex: 1;
    min-width: 220px;
    padding: 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.resumen-metodo-card:hover {
    border-color: var(--navy-light);
    background: var(--gray-50);
}

.resumen-metodo-card.selected {
    border-color: var(--navy);
    background: #e8f0fe;
    box-shadow: 0 2px 8px rgba(0, 51, 102, 0.15);
}

.metodo-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 4px;
}

.metodo-desc {
    font-size: 11px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.metodo-total {
    font-size: 22px;
    font-weight: 700;
    color: var(--navy);
}

.metodo-ahorro {
    font-size: 12px;
    color: var(--success);
    font-weight: 600;
    margin-top: 6px;
    padding: 4px 8px;
    background: #d4edda;
    border-radius: 4px;
    display: inline-block;
}

/* ===== DESGLOSE ===== */
.desglose-content {
    margin-top: 12px;
}

.desglose-section {
    margin-bottom: 12px;
}

.desglose-section h4 {
    font-size: 13px;
    color: var(--navy);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--gray-200);
}

.desglose-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
}

.desglose-table th {
    background: var(--navy);
    color: var(--white);
    padding: 6px 8px;
    text-align: left;
    font-weight: 500;
}

.desglose-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--gray-100);
}

.desglose-table tr:nth-child(even) { background: var(--gray-50); }

.desglose-table .text-right { text-align: right; }

.desglose-totals {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--navy);
    color: var(--white);
    border-radius: 4px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
}

/* ===== RESUMEN ===== */
.resumen-grid {
    max-width: 400px;
    margin-left: auto;
}

.resumen-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 15px;
    border-bottom: 1px solid var(--gray-100);
}

.resumen-total {
    font-size: 20px;
    font-weight: 700;
    color: var(--navy);
    border-bottom: none;
    border-top: 2px solid var(--navy);
    padding-top: 12px;
    margin-top: 4px;
}

.resumen-value { font-weight: 600; }

.resumen-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ===== GUARDADAS ===== */
.guardadas-list { min-height: 100px; }

.guardada-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    margin-bottom: 8px;
    background: var(--gray-50);
    transition: background 0.2s;
}

.guardada-item:hover { background: var(--gray-100); }

.guardada-info {
    flex: 1;
}

.guardada-info strong {
    color: var(--navy);
    font-size: 15px;
}

.guardada-info span {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.guardada-total {
    font-weight: 700;
    color: var(--navy);
    font-size: 16px;
    margin: 0 20px;
}

.guardada-actions {
    display: flex;
    gap: 8px;
}

.empty-msg {
    text-align: center;
    color: var(--gray-400);
    padding: 40px;
    font-size: 14px;
}

/* ===== PRECIOS TAB ===== */
.precios-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.precio-tab {
    padding: 8px 16px;
    border: 1px solid var(--gray-300);
    background: var(--white);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.precio-tab:hover { border-color: var(--navy); color: var(--navy); }
.precio-tab.active {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
}

.precio-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.precio-table th {
    background: var(--navy);
    color: var(--white);
    padding: 10px 12px;
    text-align: left;
    font-weight: 500;
    position: sticky;
    top: 0;
}

.precio-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-100);
}

.precio-table tr:nth-child(even) { background: var(--gray-50); }
.precio-table tr:hover { background: #e8f0fe; }

.precio-table input {
    width: 100px;
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
    text-align: right;
}

.precio-table input:focus {
    outline: none;
    border-color: var(--navy);
}

.precio-actions {
    margin-top: 12px;
    text-align: right;
}

/* ===== Pestaña Herrajes en Admin Precios ===== */
.herrajes-admin-table { font-size: 12px; }
.herrajes-admin-table td { padding: 4px 6px; vertical-align: middle; }
.herrajes-admin-table th { padding: 6px 6px; }
.herraje-admin-img-cell { text-align: center; padding: 2px !important; }
.herraje-admin-img {
    width: 42px; height: 42px; object-fit: contain;
    border: 1px solid var(--gray-200); border-radius: 4px; background: #fff;
    display: block; margin: 0 auto;
}
.herraje-admin-noimg {
    display: inline-block; width: 42px; height: 42px; line-height: 42px;
    text-align: center; color: var(--gray-400); font-size: 14px;
    border: 1px dashed var(--gray-300); border-radius: 4px;
}
.herraje-admin-desc {
    max-width: 380px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 11px; color: var(--gray-600);
}
.herrajes-pagination-info {
    padding: 8px 0; font-size: 12px; color: var(--gray-600);
}
.herrajes-pagination-controls {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 12px 0; flex-wrap: wrap;
}
.herrajes-page-info { font-size: 12px; color: var(--gray-700); margin: 0 12px; }

/* ===== ADMIN PRECIOS v2 (Fases 1-3) ===== */
.precio-retro-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-left: 4px solid #ffc107;
    color: #856404;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
    line-height: 1.4;
}
.precio-retro-banner .btn-link {
    background: none;
    border: none;
    color: var(--navy);
    text-decoration: underline;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 0;
    margin-left: 6px;
}
.precio-retro-banner .btn-link:hover { color: #0f3a6b; }

.precio-alert-banner {
    background: #f8d7da;
    border: 1px solid #dc3545;
    border-left: 4px solid #dc3545;
    color: #721c24;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}

.precio-meta-bar {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--gray-700, #374151);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}
.precio-meta-bar span { display: inline-block; }
.precio-meta-bar strong { color: var(--navy); }

.precio-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.precio-search-input {
    flex: 1;
    min-width: 220px;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font);
}
.precio-search-input:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 2px rgba(30,64,130,0.15);
}

.precio-section-title {
    margin: 18px 0 8px 0;
    font-size: 14px;
    color: var(--navy);
    font-weight: 600;
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 4px;
}

.precio-note {
    font-size: 12px;
    color: var(--gray-600, #6b7280);
    margin: 4px 0 10px 0;
    font-style: italic;
}

.precio-no-results {
    padding: 20px;
    text-align: center;
    color: var(--gray-600, #6b7280);
    font-style: italic;
}

.precio-table-wrap {
    max-height: 520px;
    overflow-y: auto;
    overflow-x: auto;  /* Fix BUG #6: tabla herrajes admin de 10 col en móvil */
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    margin-bottom: 8px;
}

.precio-table-sm { font-size: 12px; }
.precio-table-sm td, .precio-table-sm th { padding: 6px 10px; }

.precio-table .cod-cell {
    font-family: monospace;
    font-weight: 600;
    color: var(--navy);
}
.precio-table .base-price {
    color: var(--gray-600, #6b7280);
    font-size: 12px;
    white-space: nowrap;
}
.precio-table .ts-cell {
    font-size: 11px;
    color: var(--gray-600, #6b7280);
    white-space: nowrap;
}

.row-custom {
    background: #fff9e6 !important;
}
.row-custom:hover { background: #fff3cc !important; }

.row-pendiente {
    background: #fef2f2 !important;
}
.tag-pendiente {
    display: inline-block;
    background: #dc3545;
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: 600;
}

.precio-input-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.precio-input-wrap.is-custom .precio-input {
    border-color: #d97706;
    background: #fffbeb;
}
.custom-tag {
    font-size: 12px;
    color: #d97706;
    cursor: help;
}

.btn-reset-row {
    background: none;
    border: 1px solid var(--gray-300);
    color: var(--gray-600, #6b7280);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: all 0.15s;
}
.btn-reset-row:hover {
    border-color: var(--navy);
    color: var(--navy);
    background: #e8f0fe;
}

.custom-count-badge {
    display: inline-block;
    background: #d97706;
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 10px;
}

.precio-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
    gap: 10px;
    flex-wrap: wrap;
}
.precio-actions-bar .actions-left,
.precio-actions-bar .actions-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.precio-meta-editable {
    background: var(--gray-50);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 14px;
    border: 1px solid var(--gray-200);
}
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    margin: 8px 0;
}
.meta-grid label {
    font-size: 12px;
    color: var(--gray-600, #6b7280);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.meta-grid input {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font);
}

.precio-family {
    margin-bottom: 8px;
}
.precio-family summary {
    cursor: pointer;
    padding: 8px 12px;
    background: var(--gray-100);
    border-radius: 4px;
    font-weight: 600;
    color: var(--navy);
    user-select: none;
    margin-bottom: 4px;
}
.precio-family summary:hover { background: var(--gray-200); }

/* Bulk-edit modal */
.bulk-edit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}
.bulk-edit-modal {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    width: min(460px, 94vw);
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.bulk-edit-modal h3 {
    margin: 0 0 12px 0;
    color: var(--navy);
}
.bulk-edit-modal .form-group { margin-bottom: 12px; }
.bulk-edit-modal .form-group label {
    font-size: 12px;
    color: var(--gray-600, #6b7280);
    display: block;
    margin-bottom: 4px;
}
.bulk-edit-modal input,
.bulk-edit-modal select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font);
    box-sizing: border-box;
}
.bulk-edit-modal .modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 14px;
}

.bulk-preview .precio-input {
    border-color: #2563eb !important;
    background: #eff6ff !important;
}
.bulk-preview-badge {
    display: inline-block;
    background: #2563eb;
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
}

.error-msg {
    padding: 12px;
    background: #f8d7da;
    color: #721c24;
    border-radius: 6px;
    font-size: 13px;
}

/* ===== USUARIOS TABLE ===== */
.usuario-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    margin-bottom: 8px;
}

.usuario-info { flex: 1; }
.usuario-info strong { color: var(--navy); }
.usuario-info .badge { margin-left: 8px; }

.usuario-actions { display: flex; gap: 8px; }

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    padding: 30px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content h3 {
    color: var(--navy);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ===== SECCIONES (personalizacion de divisiones) ===== */
.balance-error .inp-seccion {
    border-color: #dc3545;
    background-color: #ffe6e6;
}
.balance-error::after {
    content: "La suma no coincide con el total";
    display: block;
    color: #dc3545;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
    flex-basis: 100%;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    .header-user { justify-content: center; }
    .form-row { flex-direction: column; gap: 8px; }
    .form-group { min-width: 100%; }
    .app-content { padding: 12px; }
    .resumen-actions { flex-direction: column; }
    .resumen-actions .btn { width: 100%; justify-content: center; }
}

/* ===== DASHBOARD SALUD ===== */
.salud-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    display: inline-block;
    vertical-align: top;
    width: calc(33.33% - 12px);
    margin-right: 12px;
    min-width: 260px;
    box-sizing: border-box;
}
.salud-card h3 { margin: 0 0 8px; font-size: 14px; color: #333; }
.salud-big { font-size: 32px; font-weight: bold; color: #1a73e8; margin: 4px 0; }
.salud-bar { background: #e0e0e0; border-radius: 4px; height: 12px; overflow: hidden; margin-bottom: 6px; }
.salud-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.salud-ok { background: #34a853; }
.salud-warn { background: #fbbc04; }
.salud-danger { background: #ea4335; }
.salud-alert { color: #ea4335; font-weight: bold; font-size: 13px; }
.salud-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.salud-table th, .salud-table td { padding: 4px 8px; border-bottom: 1px solid #eee; text-align: left; }
.salud-table th { background: #f5f5f5; font-weight: 600; }
@media (max-width: 900px) {
    .salud-card { width: calc(50% - 12px); }
}
@media (max-width: 600px) {
    .salud-card { width: 100%; margin-right: 0; }
}

/* ===== SELECTOR HERRAJES ===== */
.herrajes-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.72);
    z-index: 1100; display: flex; align-items: center; justify-content: center;
    animation: fadeInOverlay .18s ease;
}
@keyframes fadeInOverlay { from { opacity:0 } to { opacity:1 } }

.herrajes-modal {
    background: #1e2235; border-radius: 12px; width: 96vw; max-width: 1100px;
    height: 90vh; display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,.6); overflow: hidden;
    animation: slideUpModal .2s ease;
}
@keyframes slideUpModal { from { transform: translateY(30px); opacity:0 } to { transform: translateY(0); opacity:1 } }

.herrajes-header {
    padding: 16px 20px; background: #151828;
    border-bottom: 1px solid #2d3148;
    display: flex; align-items: center; gap: 14px; flex-shrink: 0;
}
.herrajes-title { color: #e0e6ff; font-size: 17px; font-weight: 700; flex: 1; margin: 0; }
.herrajes-price-toggle { display: flex; gap: 0; border-radius: 6px; overflow: hidden; border: 1px solid #3a3f5c; }
.herrajes-radio-label {
    padding: 6px 14px; font-size: 12px; cursor: pointer; transition: background .15s;
    color: #9ba3c4; background: #1e2235; user-select: none;
}
.herrajes-radio-label input[type=radio] { display: none; }
.herrajes-radio-label.active, .herrajes-radio-label:has(input:checked) {
    background: #4a6cf7; color: #fff; font-weight: 600;
}
.btn-close-herrajes {
    background: none; border: none; color: #9ba3c4; font-size: 22px;
    cursor: pointer; line-height: 1; padding: 4px 8px; border-radius: 6px;
    transition: color .15s, background .15s;
}
.btn-close-herrajes:hover { color: #fff; background: rgba(255,255,255,.08); }

.herrajes-body {
    display: flex; flex: 1; overflow: hidden; gap: 0;
}

.herrajes-filtros {
    width: 220px; flex-shrink: 0; background: #151828;
    border-right: 1px solid #2d3148; display: flex; flex-direction: column;
    overflow-y: auto; padding: 12px;
}
.herrajes-search-wrap { position: relative; margin-bottom: 12px; }
.herrajes-search-wrap input {
    width: 100%; padding: 8px 10px 8px 32px; border-radius: 7px;
    border: 1px solid #3a3f5c; background: #1e2235; color: #e0e6ff;
    font-size: 13px; outline: none; transition: border-color .15s;
}
.herrajes-search-wrap input:focus { border-color: #4a6cf7; }
.herrajes-search-icon {
    position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
    color: #6b739e; font-size: 14px; pointer-events: none;
}
.herrajes-filter-label {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    color: #6b739e; letter-spacing: .06em; margin: 10px 0 4px;
}
.herrajes-filtros select {
    width: 100%; padding: 7px 8px; border-radius: 6px;
    border: 1px solid #3a3f5c; background: #1e2235; color: #c8d0f0;
    font-size: 12px; outline: none; cursor: pointer; margin-bottom: 4px;
}
.herrajes-filtros select:focus { border-color: #4a6cf7; }
.btn-clear-filtros {
    margin-top: 10px; width: 100%; padding: 7px; border-radius: 6px;
    border: 1px solid #3a3f5c; background: none; color: #9ba3c4;
    font-size: 12px; cursor: pointer; transition: background .15s, color .15s;
}
.btn-clear-filtros:hover { background: rgba(255,255,255,.06); color: #e0e6ff; }

.herrajes-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.herrajes-stats {
    padding: 8px 16px; font-size: 12px; color: #6b739e;
    border-bottom: 1px solid #2d3148; flex-shrink: 0;
}

.herrajes-grid-area { flex: 1; overflow-y: auto; padding: 12px; }
.herrajes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.herraje-card {
    background: #252a40; border: 1.5px solid #2d3148; border-radius: 10px;
    padding: 12px; cursor: pointer; transition: border-color .15s, transform .12s, background .15s;
    display: flex; flex-direction: column; gap: 8px; position: relative;
}
.herraje-card:hover { border-color: #4a6cf7; transform: translateY(-2px); background: #2a3050; }
.herraje-card.en-carrito { border-color: #2ecc71; background: #1e3028; }

.herraje-img-placeholder {
    width: 100%; aspect-ratio: 1; border-radius: 7px;
    background: #1e2235; display: flex; align-items: center;
    justify-content: center; font-size: 32px; color: #4a6cf7;
}
.herraje-img-placeholder img { width: 100%; height: 100%; object-fit: contain; border-radius: 7px; }
.herraje-info { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.herraje-modelo { font-size: 13px; font-weight: 700; color: #e0e6ff; line-height: 1.3; }
.herraje-sku { font-size: 10px; color: #6b739e; font-family: monospace; }
.herraje-desc { font-size: 11px; color: #9ba3c4; line-height: 1.4; }
.herraje-badges { display: flex; flex-wrap: wrap; gap: 3px; }
.badge-acabado, .badge-linea, .badge-caja {
    font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600;
}
.badge-acabado { background: #3a3f5c; color: #c8d0f0; }
.badge-linea { background: #1d3050; color: #4a90e2; }
.badge-caja { background: #2a2a20; color: #d4b44a; }

.herraje-precio { display: flex; flex-direction: column; gap: 2px; }
.precio-efectivo { font-size: 15px; font-weight: 700; color: #4a6cf7; }
.precio-lista-tachado { font-size: 11px; color: #5a6280; text-decoration: line-through; }

.herraje-qty-control {
    display: flex; align-items: center; gap: 6px;
    background: #1a1e30; border-radius: 6px; padding: 4px 8px;
}
.btn-qty-minus, .btn-qty-plus {
    width: 22px; height: 22px; border-radius: 4px; border: none;
    background: #2d3148; color: #e0e6ff; font-size: 16px; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.btn-qty-minus:hover, .btn-qty-plus:hover { background: #4a6cf7; }
.herraje-qty { font-size: 14px; font-weight: 700; color: #e0e6ff; min-width: 20px; text-align: center; }

.herrajes-empty {
    text-align: center; padding: 60px 20px; color: #6b739e; font-size: 14px;
}
.herrajes-empty .empty-icon { font-size: 40px; margin-bottom: 10px; }

.herrajes-paginacion {
    padding: 10px 12px; border-top: 1px solid #2d3148; flex-shrink: 0;
    display: flex; align-items: center; gap: 6px; justify-content: center;
}
.btn-pag {
    padding: 5px 11px; border-radius: 5px; border: 1px solid #3a3f5c;
    background: #1e2235; color: #9ba3c4; font-size: 12px; cursor: pointer;
    transition: background .15s, color .15s;
}
.btn-pag:hover:not(:disabled) { background: #4a6cf7; color: #fff; border-color: #4a6cf7; }
.btn-pag:disabled { opacity: .35; cursor: not-allowed; }
.btn-pag.active { background: #4a6cf7; color: #fff; border-color: #4a6cf7; font-weight: 700; }
.pag-info { font-size: 11px; color: #6b739e; padding: 0 6px; }

/* Carrito lateral */
.herrajes-carrito {
    width: 280px; flex-shrink: 0; background: #151828;
    border-left: 1px solid #2d3148; display: flex; flex-direction: column; overflow: hidden;
}
.herrajes-carrito-title {
    padding: 12px 14px; font-size: 13px; font-weight: 700; color: #9ba3c4;
    border-bottom: 1px solid #2d3148; display: flex; align-items: center; gap: 8px;
    flex-shrink: 0; text-transform: uppercase; letter-spacing: .05em;
}
.herrajes-carrito-badge {
    background: #4a6cf7; color: #fff; border-radius: 10px;
    font-size: 11px; padding: 1px 7px; font-weight: 700;
}
.herrajes-carrito-items { flex: 1; overflow-y: auto; padding: 8px; }
.herraje-carrito-row {
    background: #1e2235; border-radius: 7px; padding: 8px 10px;
    margin-bottom: 6px; display: flex; align-items: flex-start; gap: 8px;
}
.herraje-carrito-info { flex: 1; }
.herraje-carrito-modelo { font-size: 12px; font-weight: 600; color: #e0e6ff; }
.herraje-carrito-sku { font-size: 10px; color: #6b739e; font-family: monospace; }
.herraje-carrito-precio { font-size: 12px; color: #4a6cf7; font-weight: 700; }
.btn-carrito-remove {
    background: none; border: none; color: #e74c3c; font-size: 16px;
    cursor: pointer; padding: 2px 4px; border-radius: 4px;
    transition: background .15s; line-height: 1;
}
.btn-carrito-remove:hover { background: rgba(231,76,60,.15); }

.herrajes-carrito-footer {
    padding: 12px 14px; border-top: 1px solid #2d3148; flex-shrink: 0;
}
.herrajes-total {
    font-size: 15px; font-weight: 700; color: #e0e6ff;
    margin-bottom: 10px; display: flex; justify-content: space-between;
}
.herrajes-total span:last-child { color: #4a6cf7; }
.btn-agregar-herrajes {
    width: 100%; padding: 11px; border-radius: 8px; border: none;
    background: linear-gradient(135deg, #4a6cf7, #3a5ce5); color: #fff;
    font-size: 14px; font-weight: 700; cursor: pointer;
    transition: opacity .15s, transform .12s; letter-spacing: .02em;
}
.btn-agregar-herrajes:hover { opacity: .88; transform: translateY(-1px); }
.btn-agregar-herrajes:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* Resumen herrajes en partida */
.herrajes-resumen-row {
    display: flex; align-items: center; gap: 8px; padding: 4px 0;
    font-size: 12px; color: #9ba3c4; border-bottom: 1px solid #2d3148;
}
.herrajes-resumen-row:last-child { border-bottom: none; }
.herrajes-resumen-modelo { flex: 1; color: #c8d0f0; font-weight: 600; }
.herrajes-resumen-precio { color: #4a6cf7; font-weight: 700; }

@media (max-width: 768px) {
    .herrajes-modal { width: 100vw; height: 100vh; border-radius: 0; }
    .herrajes-filtros { width: 180px; }
    .herrajes-carrito { width: 220px; }
    .herrajes-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 600px) {
    .herrajes-body { flex-direction: column; }
    .herrajes-filtros { width: 100%; height: auto; max-height: 200px; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid #2d3148; }
    .herrajes-carrito { width: 100%; height: 220px; border-left: none; border-top: 1px solid #2d3148; }
}

/* ===== Plan v3.0 — Jerarquia de Herrajes en Partida ===== */
.herraje-mode-switch {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px dashed #d0d7e8;
    margin-bottom: 6px;
}
.herraje-mode-switch label {
    cursor: pointer;
    font-weight: 500;
    color: #2e3648;
}
.herraje-mode-switch input[type="radio"] { margin-right: 4px; }

.herraje-hierarchy-row select {
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid #c6d0e0;
    border-radius: 4px;
    background: #fff;
}
.herraje-hierarchy-row select:disabled {
    background: #f0f2f8;
    color: #99a2b3;
    cursor: not-allowed;
}

.herraje-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 0;
}
.acabado-chip {
    display: inline-block;
    padding: 3px 10px;
    background: #eef2fa;
    color: #2e3648;
    border: 1px solid #c6d0e0;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    user-select: none;
}
.acabado-chip:hover { background: #dfe6f5; }
.acabado-chip.active {
    background: #4a6cf7;
    color: #fff;
    border-color: #3a5ce0;
    font-weight: 600;
}

.herraje-precio-preview {
    background: #f7faff;
    padding: 4px 8px;
    border-radius: 4px;
    border-left: 2px solid #4a6cf7;
    margin-top: 4px;
}

.sel-herraje-sku {
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid #c6d0e0;
    border-radius: 4px;
    background: #fff;
}

.btn-herraje-kit-abrir:hover {
    background: #3a5ce0 !important;
}

@media (max-width: 640px) {
    .herraje-hierarchy-row { flex-direction: column; }
    .herraje-hierarchy-row select { width: 100%; }
}

/* ===== PRINT ===== */
@media print {
    .app-header, .app-nav, .resumen-actions, .btn { display: none; }
    .panel { box-shadow: none; border: 1px solid #ccc; }
}

/* ============================================
   v2 abril 2026 — Roles, status flow, read-only
   ============================================ */

/* Ocultar columnas de costo / margen / desglose para roles no-admin */
body.role-ventas .col-costo,
body.role-ventas .col-margen,
body.role-ventas .btn-toggle-desglose,
body.role-ventas .resultado-desglose,
body.role-produccion .col-costo,
body.role-produccion .col-margen,
body.role-produccion .col-precio-cuprum,
body.role-produccion .btn-toggle-desglose,
body.role-produccion .resultado-desglose,
body.role-compras .col-margen,
body.role-compras .btn-toggle-desglose,
body.role-compras .resultado-desglose {
    display: none !important;
}

/* Modo solo-lectura visual (compras/produccion abriendo guardada) */
body.role-produccion .form-input:disabled,
body.role-produccion .form-select:disabled,
body.role-produccion textarea:disabled,
body.role-compras .form-input:disabled,
body.role-compras .form-select:disabled,
body.role-compras textarea:disabled {
    background: #f3f3f3;
    color: #555;
    cursor: not-allowed;
}

/* Badge nuevo: produccion */
.badge-produccion {
    background: #6f42c1;
    color: #fff;
}

/* Stepper de estado */
.status-flow-stepper {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 10px;
}
.status-step {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
}
.status-step.done    { background: #d4edda; color: #155724; }
.status-step.current { background: #003366; color: #fff; font-weight: bold; }
.status-step.pending { background: transparent; color: #999; }
.status-step-num {
    display: inline-block;
    width: 18px; height: 18px; line-height: 18px;
    text-align: center;
    border-radius: 50%;
    background: rgba(0,0,0,0.1);
    font-size: 10px;
    font-weight: bold;
}
.status-step.current .status-step-num { background: rgba(255,255,255,0.25); }
.status-step-sep {
    width: 14px; height: 1px; background: #ccc;
}
.status-flow-actions {
    margin-top: 6px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Badges de status en lista de guardadas */
.badge-status-borrador        { background: #6c757d; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge-status-enviada_cliente { background: #17a2b8; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge-status-aceptada        { background: #28a745; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge-status-en_produccion   { background: #fd7e14; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge-status-fabricada       { background: #6f42c1; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge-status-instalada       { background: #20c997; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge-status-cobrada         { background: #003366; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge-status-perdida         { background: #d9534f; color: #fff; padding: 2px 6px; border-radius: 3px; }

/* ============================================================
   CRM — Clientes, Seguimiento, Dashboard (abril 2026, M1-M14)
   ============================================================ */

/* Badges de tipo de cliente */
.badge-tipo-constructora   { background: #0d6efd; color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.badge-tipo-desarrolladora { background: #6610f2; color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.badge-tipo-particular     { background: #20c997; color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.badge-tipo-maquila        { background: #795548; color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.badge-tipo-mostrador      { background: #6c757d; color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; }

/* Badges de probabilidad (gradiente rojo → verde) */
.badge-prob-10 { background: #dc3545; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge-prob-25 { background: #fd7e14; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge-prob-50 { background: #ffc107; color: #212529; padding: 2px 6px; border-radius: 3px; }
.badge-prob-75 { background: #8bc34a; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge-prob-90 { background: #28a745; color: #fff; padding: 2px 6px; border-radius: 3px; }

/* Panel Seguimiento colapsable */
.seguimiento-panel { margin: 12px 0; padding: 12px 14px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; }
.seguimiento-panel .panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.seguimiento-panel .panel-title { margin: 0; font-size: 15px; }
.seg-bit-list { max-height: 320px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 4px; background: #fff; }
.seg-bit-row { padding: 6px 10px; border-bottom: 1px solid #f0f0f0; font-size: 12px; }
.seg-bit-row:last-child { border-bottom: none; }
.seg-bit-auto { background: #f5f5f5; color: #666; font-style: italic; }
.seg-bit-meta { font-size: 11px; color: #555; }
.seg-bit-canal { text-transform: uppercase; font-weight: 600; color: #0d6efd; }
.seg-bit-fecha { color: #777; }
.seg-bit-resumen { margin-top: 2px; color: #212529; white-space: pre-wrap; }

/* Cotización con próximo_contacto vencido (🔔) */
.guardada-vencida { border-left: 4px solid #dc3545; background: #fff5f5; }

/* Tabla CRM (Clientes + Dashboard) */
.crm-tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.crm-tabla th, .crm-tabla td { padding: 6px 8px; text-align: left; border-bottom: 1px solid #e5e7eb; }
.crm-tabla th { background: #f3f4f6; font-weight: 600; }
.crm-tabla tr.crm-inactivo { color: #999; text-decoration: line-through; background: #fafafa; }

/* Cliente inactivo (M12): fila gris + tachado */
.cliente-inactivo td { color: #999; }

/* Banner snapshot desincronizado (M1) */
.snapshot-warn-banner { background: #fff3cd; border: 1px solid #ffc107; color: #856404; padding: 8px 12px; border-radius: 4px; margin: 6px 0; font-size: 13px; }

/* Dashboard CRM */
.crm-dashboard .dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.crm-dashboard .dash-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 12px 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.crm-dashboard .dash-card h4 { margin: 0 0 6px; font-size: 13px; color: #555; text-transform: uppercase; letter-spacing: 0.4px; }
.crm-dashboard .dash-card .big-num { font-size: 22px; font-weight: 700; color: #212529; }
.crm-dashboard .dash-card .sub { font-size: 12px; color: #777; }

/* Embudo (barras CSS puras) */
.crm-embudo { margin-top: 12px; }
.crm-embudo-row { display: grid; grid-template-columns: 140px 1fr 140px; align-items: center; gap: 10px; margin-bottom: 6px; }
.crm-embudo-label { font-size: 12px; font-weight: 600; color: #333; }
.crm-embudo-bar { background: #e5e7eb; border-radius: 3px; height: 22px; overflow: hidden; }
.crm-embudo-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #17a2b8, #0d6efd); }
.crm-embudo-val { font-size: 12px; color: #555; text-align: right; }

/* Hidden utility para "+ Nuevo cliente" button cuando no hay selector */
.hidden { display: none !important; }
