/* assets/styles.css */

/* ==========================================================================
   CSS CUSTOM PROPERTIES
   Centraliza colores, radios y sombras reutilizados en todo el sistema.
   Para cambiar el color principal del sistema, edita --color-primary aquí.
   ========================================================================== */
:root {
    /* Colores principales */
    --color-primary:        #3182ce;
    --color-primary-dark:   #2b6cb0;
    --color-danger:         #e53e3e;
    --color-danger-dark:    #c53030;
    --color-success:        #38a169;
    --color-success-dark:   #276749;
    --color-warning:        #d97706;
    --color-info:           #3182ce;

    /* Neutros */
    --color-text:           #2d3748;
    --color-text-muted:     #718096;
    --color-text-light:     #a0aec0;
    --color-border:         #e2e8f0;
    --color-bg:             #f0f2f5;
    --color-surface:        #ffffff;

    /* Elevación / sombras */
    --shadow-card:          0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    --shadow-sm:            0 1px 3px rgba(0,0,0,0.04);

    /* Bordes */
    --radius-card:          14px;
    --radius-btn:           8px;
    --radius-input:         8px;
    --radius-badge:         6px;

    /* Tipografía */
    --font-family:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-sm:         0.875rem;
    --font-size-xs:         0.78rem;

    /* Transiciones */
    --transition-fast:      0.15s ease;
}

/* ==========================================================================
   DARK MODE — Sobrescribe variables CSS principales
   Los componentes con colores hardcodeados en inline styles (PHP)
   mantienen su apariencia original. Afecta: body, cards, tablas,
   inputs, botones que usan variables.
   ========================================================================== */
[data-theme="dark"] {
    /* Colores principales — versiones oscuras */
    --color-primary:        #60a5fa;
    --color-primary-dark:   #3b82f6;
    --color-danger:         #f87171;
    --color-success:        #4ade80;
    --color-warning:        #fbbf24;

    /* Neutros */
    --color-text:           #e2e8f0;
    --color-text-muted:     #94a3b8;
    --color-text-light:     #64748b;
    --color-border:         #334155;
    --color-bg:             #0f172a;
    --color-surface:        #1e293b;

    /* Sombras — más sutiles en dark mode */
    --shadow-card:          0 1px 3px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
    --shadow-sm:            0 1px 3px rgba(0,0,0,0.2);
}

/* ==========================================================================
   DARK MODE — Ajustes adicionales para elementos que no usan variables
   ========================================================================== */
[data-theme="dark"] body {
    background: #0f172a;
    color: #e2e8f0;
}
[data-theme="dark"] header {
    background: #1e293b;
    border-bottom-color: #334155;
}
[data-theme="dark"] header h1 {
    color: #f1f5f9;
}
[data-theme="dark"] nav a {
    color: #94a3b8;
}
[data-theme="dark"] nav a:hover,
[data-theme="dark"] nav a.nav-active {
    color: #60a5fa;
}
[data-theme="dark"] .card {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] table {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] th {
    background: #334155;
    color: #cbd5e1;
    border-bottom-color: #475569;
}
[data-theme="dark"] td {
    background: #1e293b;
}
[data-theme="dark"] tbody tr:hover {
    background: #334155;
}
[data-theme="dark"] .btn-secondary {
    background: #334155;
    color: #cbd5e1;
    border-color: #475569;
}
[data-theme="dark"] .btn-secondary:hover {
    background: #475569;
    border-color: #64748b;
}
[data-theme="dark"] .filter-badge:not(.active) {
    background: #334155;
    color: #94a3b8;
    border-color: #475569;
}
[data-theme="dark"] .filter-badge:not(.active):hover {
    background: #475569;
    color: #cbd5e1;
}
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96,165,250,0.15);
}
[data-theme="dark"] .form-control {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}
[data-theme="dark"] .filter-toolbar .live-search {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}
[data-theme="dark"] .filter-toolbar .live-search:focus {
    background: #1e293b;
}
[data-theme="dark"] footer {
    color: #64748b;
}
[data-theme="dark"] hr {
    border-color: #334155;
}
[data-theme="dark"] .modal-container {
    background: #1e293b;
}
[data-theme="dark"] .modal-header {
    border-bottom-color: #334155;
}
[data-theme="dark"] .modal-title {
    color: #f1f5f9;
}
[data-theme="dark"] .modal-body {
    color: #cbd5e1;
}
[data-theme="dark"] fieldset {
    border-color: #334155;
}
[data-theme="dark"] legend {
    color: #cbd5e1;
}

/* ── Títulos y headings en dark mode ── */
[data-theme="dark"] .page-header h2,
[data-theme="dark"] .card > h2,
[data-theme="dark"] .card h2,
[data-theme="dark"] h2 {
    color: #f1f5f9;
}
[data-theme="dark"] .card > h3,
[data-theme="dark"] .card h3,
[data-theme="dark"] h3 {
    color: #e2e8f0;
}
[data-theme="dark"] .card h2:not([style*="color"]) {
    color: #f1f5f9;
}
[data-theme="dark"] h1 {
    color: #f1f5f9;
}
[data-theme="dark"] .highlight {
    color: #60a5fa;
}
[data-theme="dark"] .indicador-titulo {
    color: #e2e8f0;
}
[data-theme="dark"] .stock-card-nombre {
    color: #f1f5f9;
}
[data-theme="dark"] .units-panel-header strong {
    color: #e2e8f0;
}

/* ==========================================================================
   GLOBAL RESET & BASE
   ========================================================================== */
/* Global reset */
*, *::before, *::after {
    box-sizing: border-box;
}
html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f0f2f5;
    color: #2d3748;
    line-height: 1.5;
}
header {
    text-align: center;
    padding: 20px 10px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.header-logo img {
    max-width: 120px;
    height: auto;
    display: block;
    margin: 0 auto 8px;
}
header h1 {
    margin: 8px 0;
    font-size: 1.6rem;
    font-weight: 600;
    color: #1a202c;
}
header h1 .highlight {
    color: #3182ce;
}
nav {
    margin-top: 10px;
}
footer {
    text-align: center;
    padding: 16px 20px;
    font-size: 0.85rem;
    color: #a0aec0;
}
nav a {
    color: #4a5568;
    text-decoration: none;
    margin: 0 10px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.15s;
}
nav a:hover {
    color: #3182ce;
    text-decoration: none;
}
nav a.nav-active {
    color: #3182ce;
    font-weight: 700;
    border-bottom: 2px solid #3182ce;
    padding-bottom: 2px;
}
main {
    padding: 24px 20px;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
}
.card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid #e8ecf1;
}
.home-grid {
    display: grid;
    gap: 20px;
}
@media (min-width: 768px) {
    .home-grid { grid-template-columns: repeat(2,1fr); }
}
@media (min-width: 1024px) {
    .home-grid { grid-template-columns: repeat(4,1fr); }
}
.home-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    color: #fff;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
    font-weight: 600;
    font-size: 0.95rem;
}
.home-button svg {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    fill: #fff;
}
.home-button.red { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.home-button.blue { background: linear-gradient(135deg, #3498db, #2980b9); }
.home-button:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.12); }

.btn-red { background: #e53e3e; color: #fff; border: none; padding: 8px 16px; border-radius: 8px; text-decoration: none; display: inline-block; cursor: pointer; font-size: 0.88rem; font-weight: 600; transition: background 0.15s, transform 0.1s; }
.btn-blue { background: #3182ce; color: #fff; border: none; padding: 8px 16px; border-radius: 8px; text-decoration: none; display: inline-block; cursor: pointer; font-size: 0.88rem; font-weight: 600; transition: background 0.15s, transform 0.1s; }
.btn-small { padding: 8px 16px; font-size: 0.82rem; border-radius: 7px; white-space: nowrap; }
.btn-red:hover { background: #c53030; }
.btn-blue:hover { background: #2b6cb0; }
.btn-green { background: #38a169; color: #fff; border: none; padding: 8px 16px; border-radius: 8px; text-decoration: none; display: inline-block; cursor: pointer; font-size: 0.88rem; font-weight: 600; transition: background 0.15s, transform 0.1s; }
.btn-green:hover { background: #276749; }

/* new button system */
.btn-primary { background: linear-gradient(135deg, #3182ce, #2b6cb0); color: #fff; border: none; padding: 10px 18px; border-radius: 8px; font-weight: 600; display: inline-block; cursor: pointer; font-size: 0.88rem; transition: transform 0.1s, box-shadow 0.15s; text-decoration: none; }
.btn-secondary { background: #fff; color: #4a5568; border: 1.5px solid #e2e8f0; padding: 9px 16px; border-radius: 8px; display: inline-block; cursor: pointer; font-size: 0.88rem; font-weight: 600; transition: border-color 0.15s, background 0.15s; text-decoration: none; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(49, 130, 206, 0.25); }
.btn-secondary:hover { border-color: #cbd5e0; background: #f7fafc; }
.back-link { display: inline-block; margin-top: 20px; color: #4a5568; text-decoration: none; font-weight: 500; }
.back-link:hover { color: #3182ce; }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid #e8ecf1; }
th, td { background: #fff; padding: 12px 14px; text-align: left; vertical-align: middle; }

/* table row separators and hover */
tbody tr { border-bottom: 1px solid #f0f0f0; transition: background 0.1s; }
tbody tr:hover { background: #f7fafc; }
th { background: #f7fafc; color: #4a5568; font-weight: 700; text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.04em; border-bottom: 2px solid #e2e8f0; white-space: nowrap; }
/* also style tr > th for headerless tables */
tr:first-child > th { background: #f7fafc; }

/* helper classes for table columns */
.col-nowrap { white-space: nowrap; }

/* ===== Celda con texto truncado + "Ver más" ===== */
/* Applies ONLY to td.cell-truncate — no global side effects */
td.cell-truncate {
    max-width: 300px;
    min-width: 140px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    position: relative;
}
td.cell-truncate .cell-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.45;
}
td.cell-truncate .cell-text--empty { color: #a0aec0; font-style: italic; }
.btn-vermas {
    background: none;
    border: none;
    color: #3182ce;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 0 0;
    display: inline-block;
    transition: color 0.12s;
}
.btn-vermas:hover { color: #2b6cb0; text-decoration: underline; }

/* ===== Modal global reutilizable ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-overlay.modal-visible {
    opacity: 1;
    pointer-events: auto;
}
.modal-container {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    width: 92%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.2s ease;
}
.modal-visible .modal-container {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #e8ecf1;
}
.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a202c;
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #a0aec0;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.12s;
}
.modal-close:hover { color: #e53e3e; }
.modal-body {
    padding: 16px 20px 20px;
    overflow-y: auto;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #2d3748;
}

/* ===== Modal: Selector de ítems (presupuesto) ===== */
.modal-items-container {
    max-width: 960px;
    width: 95%;
    max-height: 85vh;
}
.modal-items-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.modal-items-search-input {
    flex: 1;
    min-width: 200px;
    padding: 7px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.92rem;
}
.modal-items-search-input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.2);
}
.modal-items-filter-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
.modal-items-filter-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: #4a5568;
    white-space: nowrap;
}
.modal-items-filter-select {
    padding: 6px 10px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.88rem;
    min-width: 160px;
}
.modal-items-table-wrap {
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.modal-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.modal-items-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}
.modal-items-table th {
    background: #f7fafc;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}
.modal-items-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #edf2f7;
    vertical-align: middle;
}
.modal-items-table tbody tr:hover {
    background: #ebf8ff;
}
.modal-items-table .col-num {
    text-align: right;
    white-space: nowrap;
}
.modal-desc-cell {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #718096;
    font-size: 0.85rem;
}
.btn-modal-select {
    white-space: nowrap;
    padding: 4px 12px !important;
    font-size: 0.82rem !important;
}

/* ===== Badges (estados de presupuesto) ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-gray   { background: #e2e8f0; color: #4a5568; }
.badge-blue   { background: #bee3f8; color: #2a4365; }
.badge-green  { background: #c6f6d5; color: #22543d; }
.badge-red    { background: #fed7d7; color: #9b2c2c; }
.badge-orange { background: #fefcbf; color: #975a16; }

/* ===== Formulario de presupuesto ===== */
.pform-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.pform-grid label { display: block; font-size: 0.88rem; font-weight: 600; }
.pform-grid select, .pform-grid input {
    width: 100%;
    margin-top: 4px;
}
.pform-section {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 18px;
}
.pform-section legend {
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0 6px;
    color: #2d3748;
}
.pform-cliente-info {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.pform-cliente-info label { display: block; font-size: 0.85rem; font-weight: 600; }
.pform-cliente-info input { width: 100%; margin-top: 4px; background: #f7fafc; }

/* Dropdown de búsqueda AJAX */
.dropdown-list {
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    z-index: 500;
    background: #fff;
    border: 1px solid #cbd5e0;
    border-radius: 0 0 8px 8px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 4px 14px rgba(0,0,0,0.10);
}
.dropdown-item {
    padding: 8px 12px;
    font-size: 0.88rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}
.dropdown-item:hover { background: #ebf8ff; }
.dropdown-item.disabled { color: #a0aec0; cursor: default; }
.dropdown-item.disabled:hover { background: #fff; }
.dropdown-item small { color: #718096; }

/* Inputs pequeños dentro de la tabla de ítems */
.input-sm {
    padding: 5px 8px;
    font-size: 0.83rem;
    border: 1px solid #cbd5e0;
    border-radius: 5px;
    width: 100%;
}
.input-number {
    text-align: right;
    width: 100px;
}
.item-desc-cell {
    width: 108px;
    max-width: 108px;
    font-size: 0.82rem;
    color: #4a5568;
}
/* Nombre en tabla de ítems del presupuesto */
.item-nombre-cell {
    overflow: hidden;
    max-width: 240px;
}
.item-nombre-display {
    display: block;
    width: 100%;
    max-width: 240px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.35;
}
/* Tabla de ítems: anchos fijos para que columnas no se expandan */
#items-table { table-layout: fixed; min-width: 860px; }
.item-line-total {
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
}

/* Totales del formulario */
.pform-totals {
    max-width: 320px;
    margin-left: auto;
    margin-top: 12px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 18px;
}
.pform-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.9rem;
}
.pform-totals-final {
    border-top: 2px solid #2d3748;
    margin-top: 6px;
    padding-top: 8px;
    font-size: 1rem;
}

.pform-client-search {
    position: relative;
    max-width: 400px;
}
.pform-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
    align-items: center;
}

/* two-column layout with a side panel for bitácora */
.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 20px;
    align-items: start;
}
.main-col {
    min-width: 0;
}
.side-col {
    min-width: 0;
}
.side-col .card {
    margin: 0;
}
.note {
    border: 1px solid #e8ecf1;
    padding: 12px;
    background: #f9fafb;
    margin-bottom: 10px;
    border-radius: 10px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.note-date {
    font-size: 0.78rem;
    color: #a0aec0;
    margin-right: 8px;
    min-width: 120px;
    font-weight: 500;
}
.note-text {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    flex: 1;
    min-width: 0;
}
.note form {
    margin: 0;
    display: flex;
    flex-shrink: 0;
    align-self: flex-start;
}
.note button { margin-left: 12px; }

/* ensure textarea styles are reasonable */
textarea {
    font-family: inherit;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
}

small {
    font-size: 0.85rem;
    color: #555;
}

/* form error list */
.errors {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-left: 4px solid #e53e3e;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    color: #c53030;
    list-style: disc;
    margin: 0 0 16px 0;
    padding-left: 32px;
    font-size: 0.9rem;
}

.required-mark {
    color: #e53e3e;
    font-weight: bold;
}

/* page header */
.page-header h2 {
    font-size: 1.5rem;
    margin: 0 0 12px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #edf2f7;
    font-weight: 700;
    color: #1a202c;
}
.action-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0 18px 0; }
.actions-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions-right { display: flex; gap: 10px; align-items: center; }

/* note area / bitacora */
.bitacora .card { padding:16px; }

/* responsive tweaks */
@media (max-width:720px) {
    .action-bar { flex-direction:column; align-items:stretch; }
    .actions-right { justify-content:flex-start; }
}

/* small EQC meta card used in header */
.eqc-meta {
    background: #f7fafc; border: 1px solid #e2e8f0; padding: 10px 14px; border-radius: 10px; display: flex; gap: 16px; align-items: center;
}
.eqc-meta .label { color: #a0aec0; font-size: 0.78rem; margin-right: 4px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.eqc-meta .value { font-weight: 700; color: #2d3748; }

.actions-cell { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.actions-cell form { margin: 0; }
.actions-cell a, .actions-cell button { vertical-align: middle; }

/* Nav user + logout */
.nav-user {
    color: #718096;
    font-size: 0.85rem;
    margin-left: 20px;
    font-weight: 500;
}
.nav-logout {
    color: #e53e3e !important;
    font-size: 0.85rem;
    margin-left: 6px;
    font-weight: 600;
}

/* ===== Login / Register pages ===== */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(160deg, #e2e8f4 0%, #f0f4fa 40%, #e8edf6 100%);
    padding: 24px;
}
.login-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(15, 30, 60, 0.10), 0 2px 10px rgba(0,0,0,0.04);
    padding: 48px 42px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    border-top: 4px solid #2b8dd6;
}
.login-card h2 {
    font-size: 1.55rem;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: #1a1a2e;
    letter-spacing: -0.01em;
}
.login-subtitle {
    font-size: 0.88rem;
    color: #8899aa;
    margin: 0 0 32px 0;
    font-weight: 400;
}
.login-logo {
    margin-bottom: 10px;
}
.login-logo img {
    max-width: 100px;
    height: auto;
    border-radius: 12px;
    object-fit: contain;
}
.login-divider {
    height: 1px;
    background: #e8ecf1;
    margin: 24px 0;
    border: none;
}
.login-error {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    border-radius: 0 8px 8px 0;
    color: #991b1b;
    padding: 13px 16px;
    margin-bottom: 22px;
    font-size: 0.88rem;
    text-align: left;
    line-height: 1.55;
}
.login-success {
    background: #f0fdf4;
    border-left: 4px solid #22c55e;
    border-radius: 0 8px 8px 0;
    color: #166534;
    padding: 16px;
    margin-bottom: 18px;
    font-size: 0.92rem;
    text-align: left;
    line-height: 1.55;
}
.login-success a {
    color: #166534;
    font-weight: 700;
}
.form-group {
    margin-bottom: 20px;
    text-align: left;
}
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 7px;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8f9fb;
    color: #1a1a2e;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2b8dd6;
    box-shadow: 0 0 0 3px rgba(43, 141, 214, 0.13);
    background: #fff;
}
.form-group input::placeholder {
    color: #aab4c2;
}
.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}
.btn-login {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #2b8dd6 0%, #1a6fb5 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
    margin-top: 8px;
    letter-spacing: 0.02em;
}
.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(43, 141, 214, 0.3);
}
.btn-login:active {
    transform: translateY(0);
}
.login-footer {
    margin-top: 26px;
    font-size: 0.88rem;
    color: #8899aa;
    padding-top: 20px;
    border-top: 1px solid #eef1f6;
}
.login-footer a {
    color: #2b8dd6;
    text-decoration: none;
    font-weight: 600;
}
.login-footer a:hover {
    text-decoration: underline;
}

/* ===== Nav admin link ===== */
.nav-admin {
    color: #2b8dd6 !important;
    font-weight: 700;
}

/* ===== Admin Users Panel ===== */
.admin-panel {
    max-width: 900px;
    margin: 0 auto;
}
.admin-msg {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.admin-msg-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}
.admin-msg-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
}
.admin-section {
    margin-bottom: 32px;
}
.admin-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    margin: 0 0 14px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.pending-title {
    color: #b45309;
}
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
}
.badge-warning { background: #f59e0b; }
.badge-active  { background: #22c55e; }
.badge-inactive { background: #94a3b8; }

.admin-empty {
    color: #999;
    font-size: 0.9rem;
    font-style: italic;
    margin: 0;
}
.admin-table-wrap {
    overflow-x: auto;
}
.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #eef2f5;
}
.admin-table th {
    background: #f8f9fb;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #666;
    padding: 10px 14px;
    text-align: left;
}
.admin-table td {
    padding: 12px 14px;
    border-top: 1px solid #f0f0f0;
    vertical-align: middle;
}
.admin-table tbody tr:hover {
    background: #fafbfc;
}
.admin-label {
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
}

/* Admin action buttons */
.btn-approve {
    background: #22c55e;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-approve:hover { background: #16a34a; }

.btn-reject {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-reject:hover { background: #dc2626; }

.btn-deactivate {
    background: transparent;
    color: #ef4444;
    border: 1px solid #fca5a5;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-deactivate:hover {
    background: #fef2f2;
}

.btn-reactivate {
    background: transparent;
    color: #22c55e;
    border: 1px solid #86efac;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-reactivate:hover {
    background: #f0fdf4;
}

/* Login info message (pending/inactive) */
.login-info {
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
    border-radius: 0 8px 8px 0;
    color: #1e40af;
    padding: 12px 14px;
    margin-bottom: 20px;
    font-size: 0.88rem;
    text-align: left;
    line-height: 1.5;
}

/* ===== Admin inline role selector ===== */
.role-form {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.role-select {
    padding: 5px 28px 5px 10px;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.84rem;
    background: #f8f9fb;
    color: #333;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
    transition: border-color 0.15s;
}
.role-select:focus {
    outline: none;
    border-color: #2b8dd6;
    box-shadow: 0 0 0 2px rgba(43, 141, 214, 0.12);
}
.btn-role-save {
    padding: 5px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    background: #2b8dd6;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn-role-save:hover {
    background: #1a6fb5;
}
.estado-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.estado-pendiente { background: #fef3c7; color: #92400e; }
.estado-activo    { background: #dcfce7; color: #166534; }
.estado-inactivo  { background: #f1f5f9; color: #64748b; }

/* ===== Responsive Table Wrapper ===== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
}
.table-wrap table {
    width: auto;
    min-width: 100%;
}

/* ===== Mobile Navigation Toggle ===== */
.nav-toggle {
    display: none;
    background: none;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #4a5568;
    margin: 10px auto 0;
    line-height: 1;
    transition: background 0.15s;
}
.nav-toggle:hover {
    background: #f7fafc;
}

/* ===== CRUD Form Styling ===== */
form p label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
}
form p label input[type="text"],
form p label input[type="email"],
form p label input[type="password"],
form p label input[type="date"],
form p label input[type="number"],
form p label input[type="tel"],
form p label select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-top: 4px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8f9fb;
    color: #1a1a2e;
}
form p label textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-top: 4px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8f9fb;
    color: #1a1a2e;
    resize: vertical;
}
form p label input:focus,
form p label select:focus,
form p label textarea:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.12);
    background: #fff;
}
form p label select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}
form p label input[type="file"] {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
}

/* ===== Search Forms ===== */
.search-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.search-form input[type="text"] {
    flex: 1;
    min-width: 180px;
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
    background: #f8f9fb;
}
.search-form input[type="text"]:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.12);
    background: #fff;
}

/* ===== Card heading styles ===== */
.card > h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #edf2f7;
}
.card > h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2d3748;
    margin: 20px 0 12px 0;
}

/* ===== Responsive Media Queries ===== */

/* Tablet and below */
@media (max-width: 900px) {
    main {
        padding: 16px 12px;
    }
    .card {
        padding: 18px;
    }
    .two-col {
        flex-direction: column;
    }
    .side-col {
        max-width: 100%;
    }
    .eqc-meta {
        flex-wrap: wrap;
    }
}

/* ===== Mobile: Table → Cards ===== */
@media (max-width: 768px) {
    header {
        padding: 16px 10px;
    }
    header h1 {
        font-size: 1.3rem;
    }

    /* Navigation toggle */
    .nav-toggle {
        display: block;
    }
    nav {
        display: none;
        flex-direction: column;
        gap: 4px;
        padding: 12px 0;
    }
    nav.nav-open {
        display: flex;
    }
    nav a {
        padding: 10px 16px;
        margin: 0;
        border-radius: 8px;
        text-align: center;
    }
    nav a:hover {
        background: #f0f4fa;
        text-decoration: none;
    }
    .nav-user {
        display: block;
        margin: 4px 0;
        text-align: center;
        padding: 6px 16px;
    }
    .nav-logout {
        display: block;
        text-align: center;
        padding: 10px 16px;
        margin: 0;
        border-radius: 8px;
    }

    /* Main content */
    main {
        padding: 12px 10px;
    }
    .card {
        padding: 16px;
        border-radius: 12px;
    }

    /* Page headers */
    .page-header h2 {
        font-size: 1.2rem;
    }

    /* Action bars */
    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .actions-left {
        flex-wrap: wrap;
    }
    .actions-right {
        justify-content: flex-start;
    }
    .actions-left a,
    .actions-left .btn-primary,
    .actions-left .btn-secondary {
        flex: 1;
        text-align: center;
        min-width: 110px;
    }

    /* Buttons */
    .btn-blue, .btn-red, .btn-primary, .btn-secondary {
        padding: 10px 16px;
        font-size: 0.88rem;
        text-align: center;
    }

    /* Notes */
    .note {
        flex-direction: column;
        gap: 6px;
    }
    .note-date {
        min-width: unset;
    }

    /* Search forms */
    .search-form {
        flex-direction: column;
        align-items: stretch;
    }
    .search-form input[type="text"] {
        width: 100%;
        min-width: unset;
    }

    /* Pagination */
    .pagination {
        justify-content: center;
    }

    /* EQC meta */
    .eqc-meta {
        flex-direction: column;
        gap: 6px;
        padding: 12px;
    }

    /* Home grid */
    .home-button {
        padding: 20px 16px;
    }

    /* Form buttons row */
    form > p:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    form > p:last-child .btn-blue,
    form > p:last-child .btn-red,
    form > p:last-child .btn-primary,
    form > p:last-child .btn-secondary {
        flex: 1;
        text-align: center;
        min-width: 100px;
    }

    /* Login adjustments */
    .login-card {
        padding: 30px 20px 28px;
    }

    /* ========================================
       TABLE → CARD transformation on mobile
       ======================================== */
    .table-wrap {
        overflow-x: visible;
    }
    .table-wrap table,
    .table-wrap thead,
    .table-wrap tbody,
    .table-wrap th,
    .table-wrap td,
    .table-wrap tr {
        display: block;
    }
    /* Hide table header row */
    .table-wrap thead,
    .table-wrap tr:first-child:has(th) {
        display: none;
    }
    /* Also hide headerless th rows (calibraciones etc uses <tr><th>...) */
    .table-wrap tr > th {
        display: none;
    }
    /* Each row becomes a card */
    .table-wrap tbody tr,
    .table-wrap tr:not(:first-child) {
        display: block;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    }
    .table-wrap tbody tr:hover,
    .table-wrap tr:not(:first-child):hover {
        background: #fff;
        box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    }
    /* Each cell becomes a row with label */
    .table-wrap td {
        display: flex;
        align-items: flex-start;
        padding: 6px 0;
        border: none;
        background: transparent;
        font-size: 0.9rem;
        gap: 8px;
    }
    .table-wrap td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #718096;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        min-width: 110px;
        flex-shrink: 0;
        padding-top: 2px;
    }
    /* Actions cell - special styling */
    .table-wrap td.actions-cell,
    .table-wrap td[data-label="Acciones"],
    .table-wrap td:last-child:not([data-label]) {
        border-top: 1px solid #edf2f7;
        margin-top: 8px;
        padding-top: 12px;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .table-wrap td.actions-cell::before,
    .table-wrap td[data-label="Acciones"]::before {
        display: none;
    }
    /* col-nowrap should wrap on mobile cards */
    .table-wrap .col-nowrap {
        white-space: normal;
    }
    /* cell-truncate: relax on mobile cards */
    .table-wrap td.cell-truncate {
        max-width: unset;
        min-width: unset;
    }
    .table-wrap td.cell-truncate .cell-text {
        -webkit-line-clamp: 3;
    }

    /* ========================================
       ADMIN TABLE → CARD transformation
       ======================================== */
    .admin-table-wrap table,
    .admin-table-wrap thead,
    .admin-table-wrap tbody,
    .admin-table-wrap th,
    .admin-table-wrap td,
    .admin-table-wrap tr {
        display: block;
    }
    .admin-table-wrap thead {
        display: none;
    }
    .admin-table-wrap tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    }
    .admin-table-wrap tbody tr:hover {
        background: #fff;
    }
    .admin-table-wrap td {
        display: flex;
        align-items: flex-start;
        padding: 5px 0;
        border: none;
        gap: 8px;
        font-size: 0.9rem;
    }
    .admin-table-wrap td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #718096;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        min-width: 100px;
        flex-shrink: 0;
        padding-top: 2px;
    }
    .admin-table-wrap td.actions-cell::before,
    .admin-table-wrap td[data-label="Acciones"]::before {
        display: none;
    }
    .admin-table-wrap td.actions-cell,
    .admin-table-wrap td[data-label="Acciones"] {
        border-top: 1px solid #edf2f7;
        margin-top: 6px;
        padding-top: 10px;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    /* Role form stacking */
    .role-form {
        flex-wrap: wrap;
    }

    /* ========================================
       PRESUPUESTO FORM responsive
       ======================================== */

    /* Client search: full width */
    .pform-client-search {
        max-width: 100%;
    }

    /* Totals: full width, no right-align */
    .pform-totals {
        max-width: 100%;
        margin-left: 0;
    }

    /* Section padding: tighter */
    .pform-section {
        padding: 12px;
    }

    /* Two-col detail/bitácora layout: single column */
    .two-col {
        grid-template-columns: 1fr;
    }

    /* Action buttons: stack vertically */
    .pform-actions {
        flex-direction: column;
    }
    .pform-actions .btn-blue,
    .pform-actions .btn-secondary,
    .pform-actions a {
        width: 100%;
        text-align: center;
    }

    /* Modal items: full width on mobile */
    .modal-items-container {
        width: 100%;
        max-height: 92vh;
    }
}

/* ===== Presupuesto items: card layout on mobile (≤1235px) ===== */
@media (max-width: 1235px) {

    /* ── wrapper: no scroll, regular block ── */
    .pform-items-wrap {
        overflow-x: visible;
    }

    /* ── hide colgroup sizing on mobile ── */
    .pform-items-wrap colgroup { display: none; }

    /* ── table/thead/tbody/tr/td → block ── */
    .pform-items-wrap table,
    .pform-items-wrap thead,
    .pform-items-wrap tbody,
    .pform-items-wrap tr,
    .pform-items-wrap td { display: block; }

    /* ── hide header row ── */
    .pform-items-wrap thead { display: none; }

    /* ── each row = editable card ── */
    .pform-items-wrap tbody tr {
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 14px 12px;
        margin-bottom: 14px;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    }

    /* ── each cell = label + content row ── */
    .pform-items-wrap td {
        display: flex;
        flex-direction: column;
        padding: 6px 0;
        border: none;
        background: transparent;
        gap: 4px;
    }

    /* ── label from data-label ── */
    .pform-items-wrap td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #718096;
    }

    /* ── hide label for cells with no useful label (acciones) ── */
    .pform-items-wrap td[data-label="Acciones"]::before { display: none; }

    /* ── inputs, selects fill full width ── */
    .pform-items-wrap td input,
    .pform-items-wrap td select {
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* ── total line: right-align stays, bigger text ── */
    .pform-items-wrap td.item-line-total {
        font-size: 1rem;
        font-weight: 700;
        color: #2d3748;
        text-align: left;
    }

    /* ── buttons fill width ── */
    .pform-items-wrap td .btn-vermas,
    .pform-items-wrap td .btn-red {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }

    /* ── nombre display: larger on card ── */
    .pform-items-wrap .item-nombre-display {
        font-size: 0.95rem;
        max-width: 100%;
    }

    /* ── nombre cell: no overflow clipping ── */
    .pform-items-wrap .item-nombre-cell {
        max-width: 100%;
    }

    /* ── acciones cell (delete btn): top border separator ── */
    .pform-items-wrap td[data-label="Acciones"] {
        margin-top: 6px;
        padding-top: 10px;
        border-top: 1px solid #edf2f7;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.1rem;
    }
    .home-grid {
        grid-template-columns: 1fr !important;
    }
    .card > h2,
    .card h2 {
        font-size: 1.15rem;
    }
    .card > h3,
    .card h3 {
        font-size: 0.95rem;
    }
    /* data-label takes full width on very small screens */
    .table-wrap td {
        flex-direction: column;
        gap: 2px;
    }
    .table-wrap td::before {
        min-width: unset;
    }
    .admin-table-wrap td {
        flex-direction: column;
        gap: 2px;
    }
    .admin-table-wrap td::before {
        min-width: unset;
    }
}

/* ===== Indicadores ===== */
.indicadores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 8px;
}
.indicador-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px 20px;
}
.indicador-titulo {
    font-size: 1rem;
    font-weight: 700;
    color: #2d3748;
    text-align: center;
    margin: 0;
}
.indicador-chart-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
}
.indicador-leyenda {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.indicador-leyenda li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #4a5568;
}
.indicador-leyenda li strong {
    margin-left: auto;
    font-size: 0.95rem;
    color: #1a202c;
}
.dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot-azul     { background: #3b82f6; }
.dot-rojo     { background: #ef4444; }
.dot-amarillo { background: #f59e0b; }
.dot-verde    { background: #22c55e; }
.dot-naranja  { background: #f97316; }
.dot-gris     { background: #94a3b8; }

/* ===== Clientes: stats + table ===== */

/* Stats row */
.clientes-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}
.stat-card {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: #1a202c;
    line-height: 1;
}
.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #718096;
}

/* Card header */
.clientes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.clientes-titulo {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0;
}
.clientes-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Search bar */
.clientes-search {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.clientes-search-input {
    flex: 1;
    min-width: 200px;
}

/* Table enhancements */
.clientes-table thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #718096;
    background: #f7fafc;
    border-bottom: 2px solid #e2e8f0;
    padding: 10px 14px;
    white-space: nowrap;
}
.clientes-table tbody tr {
    border-bottom: 1px solid #f0f4f8;
    transition: background 0.1s;
}
.clientes-table tbody tr:hover {
    background: #f0f7ff;
}
.clientes-table tbody td {
    padding: 12px 14px;
    vertical-align: middle;
}
.col-rut    { width: 120px; }
.col-estado { width: 100px; }
.col-meta   { width: 80px; }
.col-acciones { width: 255px; white-space: nowrap; }

/* Client name link */
.cliente-nombre-link {
    font-weight: 600;
    font-size: 0.95rem;
    color: #2b6cb0;
    text-decoration: none;
    display: block;
}
.cliente-nombre-link:hover { text-decoration: underline; }

/* RUT subtitle under name */
.cliente-rut-sub {
    display: block;
    font-size: 0.78rem;
    color: #a0aec0;
    margin-top: 2px;
}

/* Muted / center helpers */
.td-muted  { color: #a0aec0; font-size: 0.88rem; }
.td-center { text-align: center; }
.td-empty  { color: #cbd5e0; }

/* Estado badges */
.badge-estado {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-estado-activo   { background: #c6f6d5; color: #276749; }
.badge-estado-inactivo { background: #f1f5f9; color: #64748b; }

/* Responsive: stats */
@media (max-width: 768px) {
    .clientes-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .clientes-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .col-rut,
    .col-meta {
        display: none;
    }
}
@media (max-width: 480px) {
    .clientes-stats {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .stat-number { font-size: 1.6rem; }
}

/* ==========================================================================
   MÓDULO: STOCK
   Estilos para stock.php — grid de productos, cards, paneles de unidades.
   ========================================================================== */

/* ── Grid de productos ── */
.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* ── Card de producto ── */
.stock-card {
    background: #fff;
    border-radius: var(--radius-card, 14px);
    border: 1px solid #e8ecf1;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Imagen del producto */
.stock-card-img {
    width: 100%;
    height: 160px;
    background: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid #e8ecf1;
}
.stock-card-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.stock-img-placeholder {
    font-size: 0.82rem;
    color: #a0aec0;
    font-style: italic;
    letter-spacing: 0.03em;
}

/* Cuerpo de la card */
.stock-card-body {
    padding: 16px 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.stock-card-nombre {
    font-size: 1rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0;
    line-height: 1.35;
}
.stock-card-meta {
    font-size: 0.83rem;
    color: #718096;
    margin: 0;
}

/* Contadores */
.stock-counters {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin: 2px 0;
}
.stock-counters span {
    font-size: 0.88rem;
    font-weight: 600;
    color: #2d3748;
}
.stock-counters em {
    font-style: normal;
    font-weight: 400;
    font-size: 0.78rem;
    color: #a0aec0;
}
.stock-count-total   { color: #2d3748 !important; }
.stock-count-asig    { color: #e53e3e !important; }
.stock-count-disp    { color: #38a169 !important; }

/* Botones de tipo en la card */
.stock-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-stock-tipo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    border: none;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.btn-disp {
    background: #c6f6d5;
    color: #22543d;
}
.btn-disp:hover { background: #9ae6b4; }
.btn-asig {
    background: #fed7d7;
    color: #9b2c2c;
}
.btn-asig:hover { background: #feb2b2; }
.stock-btn-badge {
    background: rgba(0,0,0,0.12);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.77rem;
    font-weight: 700;
}

/* Enlace pequeño */
.btn-link-sm {
    background: none;
    border: none;
    color: #3182ce;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.12s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-link-sm:hover { color: #2b6cb0; }

/* ── Panel de unidades (AJAX) ── */
.stock-units-panel {
    border-top: 1px solid #e8ecf1;
    background: #f9fafb;
}
.units-panel-inner {
    padding: 14px 16px 16px;
}
.units-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.88rem;
}
.units-panel-header strong {
    font-size: 0.9rem;
    color: #1a202c;
}
.units-count {
    color: #718096;
    font-size: 0.82rem;
}

/* Tabla de unidades */
.stock-units-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.86rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}
.stock-units-table th {
    background: #edf2f7;
    font-size: 0.78rem;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
}
.stock-units-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    background: #fff;
}
.stock-units-table tbody tr:last-child td {
    border-bottom: none;
}
.td-serie {
    font-size: 0.82rem;
    color: #4a5568;
    white-space: nowrap;
    font-family: 'Courier New', Courier, monospace;
    min-width: 120px;
}

/* Pie del panel (guardar) */
.units-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* Mensajes del módulo stock */
.stock-msg {
    font-size: 0.84rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 5px;
}
.stock-msg-success { color: #22543d; background: #c6f6d5; }
.stock-msg-error   { color: #9b2c2c; background: #fed7d7; }
.stock-msg-info    { color: #1e40af; background: #dbeafe; }

/* Flash message de página */
.stock-flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 600;
}
.stock-flash-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.stock-flash-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; }

/* Paginación del panel */
.stock-paginacion {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.btn-pag {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #4a5568;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
}
.btn-pag:hover:not(:disabled) { background: #ebf8ff; border-color: #3182ce; color: #2b6cb0; }
.btn-pag:disabled { opacity: 0.4; cursor: default; }
.btn-pag-active {
    background: #3182ce;
    color: #fff;
    border-color: #3182ce;
}
.btn-pag-active:hover { background: #2b6cb0 !important; }
.pag-info { font-size: 0.8rem; color: #a0aec0; margin-left: 6px; }

/* Estados de carga / vacío */
.stock-loading { color: #a0aec0; font-size: 0.88rem; text-align: center; padding: 12px 0; }
.stock-error   { color: #c53030; font-size: 0.88rem; padding: 8px 0; }
.stock-empty-msg { color: #a0aec0; font-size: 0.88rem; font-style: italic; padding: 8px 0; }

/* Formulario de nuevo producto */
.stock-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}
.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.92rem;
    font-family: inherit;
    background: #f8f9fb;
    color: #1a1a2e;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49,130,206,0.12);
    background: #fff;
}
input[type="file"].form-control {
    padding: 7px 10px;
    cursor: pointer;
}

/* ── Responsive ── */
/* Botón peligroso pequeño (eliminar producto) */
.btn-danger-sm {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 7px;
    border: 1.5px solid #fc8181;
    background: #fff5f5;
    color: #c53030;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-danger-sm:hover:not(:disabled) {
    background: #fed7d7;
    border-color: #e53e3e;
    color: #9b2c2c;
}
.btn-danger-sm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    .stock-grid {
        grid-template-columns: 1fr;
    }
    .stock-form-grid {
        grid-template-columns: 1fr;
    }
    .stock-card-actions {
        flex-direction: column;
    }
    .btn-stock-tipo {
        width: 100%;
        justify-content: center;
    }
}

  
/* === Mapeos + Filter badges === */  
.filter-toolbar{display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin-bottom:16px}  
.filter-toolbar .live-search{flex:1;min-width:200px;padding:10px 14px;border:1.5px solid #d1d5db;border-radius:10px;font-size:.92rem;background:#f8f9fb;box-sizing:border-box}  
.filter-toolbar .live-search:focus{outline:none;border-color:#3182ce;box-shadow:0 0 0 3px rgba(49,130,206,.12);background:#fff}  
.filter-badges{display:flex;flex-wrap:wrap;gap:6px;align-items:center}  
.filter-label{font-size:.82rem;font-weight:600;color:#718096;text-transform:uppercase;letter-spacing:.03em;margin-right:2px}  
.filter-badge{display:inline-block;padding:6px 14px;border-radius:20px;font-size:.82rem;font-weight:600;text-decoration:none;border:1.5px solid transparent;transition:all .15s;white-space:nowrap}  
.filter-badge:not(.active){background:#f1f5f9;color:#64748b;border-color:#e2e8f0}  
.filter-badge:not(.active):hover{background:#e2e8f0;color:#475569}  
.filter-badge.active{background:#3182ce;color:#fff;border-color:#3182ce;box-shadow:0 2px 6px rgba(49,130,206,.25)}  
.filter-badge.clear-badge{background:transparent;border:1.5px dashed #cbd5e0;color:#94a3b8;font-size:.78rem;padding:5px 12px}  
.filter-badge.clear-badge:hover{border-color:#94a3b8;color:#64748b} 
