/* =============================================
   ALCAR Sistema — sistema.css
   Estilos para el sistema interno (PHP)
   ============================================= */

:root {
    --red:        #BE2026;
    --red-dark:   #9e191e;
    --dark:       #1A1A2E;
    --dark-2:     #12122A;
    --white:      #FFFFFF;
    --light:      #F7F8FA;
    --gray:       #6B7280;
    --gray-light: #E5E7EB;
    --text:       #1F2937;
    --text-soft:  #6B7280;
    --radius:     10px;
    --shadow:     0 2px 12px rgba(0,0,0,.07);
    --shadow-md:  0 4px 24px rgba(0,0,0,.1);
    --transition: 0.25s ease;
    --nav-h:      60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--light);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* =============================================
   TOPNAV
   ============================================= */
.topnav {
    position: sticky;
    top: 0; z-index: 100;
    height: var(--nav-h);
    background: var(--dark-2);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.topnav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--white);
    font-size: .95rem;
    margin-right: 16px;
    white-space: nowrap;
}
.brand-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--red);
    flex-shrink: 0;
}
.topnav-links {
    display: flex;
    gap: 4px;
    flex: 1;
}
.topnav-links a {
    color: rgba(255,255,255,.75);
    font-size: .875rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 8px;
    transition: all var(--transition);
    white-space: nowrap;
}
.topnav-links a:hover { color: var(--white); background: rgba(255,255,255,.1); }
.topnav-links a.active { color: var(--white); background: rgba(255,255,255,.12); }
.topnav-cta {
    background: var(--red) !important;
    color: var(--white) !important;
}
.topnav-cta:hover { background: var(--red-dark) !important; }
.topnav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: .8rem;
    color: rgba(255,255,255,.6);
    white-space: nowrap;
}
.topnav-logout {
    color: rgba(255,255,255,.5);
    border: 1px solid rgba(255,255,255,.2);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: .8rem;
    transition: all var(--transition);
}
.topnav-logout:hover { color: var(--white); border-color: rgba(255,255,255,.5); }

/* =============================================
   LAYOUT
   ============================================= */
.main-content {
    max-width: 1160px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 1.6rem; font-weight: 800; color: var(--dark); }
.page-sub { color: var(--text-soft); font-size: .9rem; margin-top: 4px; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* =============================================
   CARDS / SECTION
   ============================================= */
.section-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--gray-light);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.card-title { font-size: 1.05rem; font-weight: 700; color: var(--dark); margin-bottom: 16px; }

.export-actions { display: flex; gap: 8px; }
.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    background: #f0f0f0;
    color: var(--dark);
    border: 1px solid #d0d0d0;
    transition: background 0.18s;
}
.btn-export:hover { background: #e0e0e0; }
.btn-export-xl { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.btn-export-xl:hover { background: #c8e6c9; }

/* =============================================
   STATS ROW
   ============================================= */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--gray-light);
    border-left: 4px solid var(--gray-light);
    transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.accent { border-left-color: var(--red); }
.stat-icon { font-size: 1.75rem; flex-shrink: 0; }
.stat-num {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--dark);
    line-height: 1;
}
.stat-num a { color: var(--red); }
.stat-card p { color: var(--text-soft); font-size: .8rem; margin-top: 2px; }

/* =============================================
   TABLAS
   ============================================= */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.data-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--light);
    font-weight: 600;
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--gray);
    border-bottom: 2px solid var(--gray-light);
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--gray-light);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--light); }
.data-table code {
    background: var(--light);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: .85em;
    color: var(--dark);
}

/* =============================================
   BADGES (líneas)
   ============================================= */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-automotriz  { background: #DBEAFE; color: #1E40AF; }
.badge-arquitectonica { background: #FEF3C7; color: #92400E; }
.badge-industrial  { background: #D1FAE5; color: #065F46; }

/* =============================================
   BOTONES
   ============================================= */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: var(--red);
    color: var(--white);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: .875rem;
    border: 2px solid var(--red);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); transform: translateY(-1px); }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: transparent;
    color: var(--text);
    border-radius: var(--radius);
    font-weight: 500;
    font-size: .875rem;
    border: 2px solid var(--gray-light);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-ghost:hover { background: var(--light); border-color: var(--gray); }

.btn-link {
    color: var(--red);
    font-size: .85rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background var(--transition);
}
.btn-link:hover { background: rgba(190,32,38,.08); }

.btn-submit {
    width: 100%;
    padding: 13px;
    background: var(--red);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background var(--transition);
    margin-top: 8px;
}
.btn-submit:hover { background: var(--red-dark); }

/* =============================================
   FORMULARIOS
   ============================================= */
.form-card { max-width: 780px; }

.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-weight: 500;
    font-size: .875rem;
    margin-bottom: 6px;
    color: var(--text);
}
.form-group input[type="text"],
.form-group input[type="tel"],
.form-group input[type="email"],
.form-group input[type="date"],
.form-group input[type="password"],
.form-group input[type="search"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-light);
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(190,32,38,.12);
}
.form-group textarea { resize: vertical; }
.form-group select { cursor: pointer; }
.required { color: var(--red); }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.form-row .form-group { margin-bottom: 0; }

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-light);
}

/* =============================================
   BÚSQUEDA
   ============================================= */
.search-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.search-input {
    flex: 1;
    min-width: 240px;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-light);
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    transition: border-color var(--transition);
}
.search-input:focus { outline: none; border-color: var(--red); }

.result-count { font-size: .8rem; color: var(--text-soft); margin-bottom: 12px; }

/* =============================================
   DETALLE (dl)
   ============================================= */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}
.detail-list { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; }
.detail-list dt { font-weight: 600; font-size: .8rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; align-self: start; padding-top: 2px; }
.detail-list dd { font-size: .9rem; color: var(--text); }
.detail-list a { color: var(--red); }
.detail-list a:hover { text-decoration: underline; }
.empty-val { color: var(--gray); }

.formula-pre {
    background: var(--light);
    border: 1px solid var(--gray-light);
    border-radius: 8px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: .875rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--dark);
}
.notas-text { font-size: .9rem; color: var(--text-soft); line-height: 1.8; }

/* =============================================
   HISTORIAL DE COLORES — TABLA COMPACTA
   ============================================= */
.color-history-table-wrap {
    overflow-x: auto;
}
.data-table-sm td,
.data-table-sm th {
    padding: 7px 12px;
    font-size: .82rem;
}
.data-table-sm code {
    font-size: .8rem;
}

/* =============================================
   ALERTAS
   ============================================= */
.alert {
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: .875rem;
    line-height: 1.5;
}
.alert p { margin: 0 0 4px; }
.alert p:last-child { margin-bottom: 0; }
.alert-error   { background: #FEE2E2; border-left: 4px solid #EF4444; color: #991B1B; }
.alert-success { background: #D1FAE5; border-left: 4px solid #10B981; color: #065F46; }

/* =============================================
   PAGINACIÓN
   ============================================= */
.pagination {
    display: flex;
    gap: 6px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}
.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid var(--gray-light);
    font-size: .875rem;
    font-weight: 500;
    transition: all var(--transition);
    color: var(--text);
}
.pagination a:hover { border-color: var(--red); color: var(--red); }
.pagination a.active { background: var(--red); border-color: var(--red); color: var(--white); }

/* =============================================
   EMPTY STATE
   ============================================= */
.empty {
    text-align: center;
    color: var(--text-soft);
    padding: 40px 20px;
    font-size: .9rem;
}
.empty a { color: var(--red); font-weight: 500; }

/* =============================================
   LOGIN
   ============================================= */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--dark-2), var(--dark));
}
.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { font-size: 3rem; margin-bottom: 12px; }
.login-header h1 { font-size: 1.5rem; font-weight: 800; color: var(--dark); }
.login-header p  { color: var(--text-soft); font-size: .875rem; margin-top: 4px; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .main-content { padding: 20px 16px 48px; }
    .section-card { padding: 20px 16px; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .topnav-links { display: none; }
    .topnav-user span { display: none; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .form-card { max-width: 100%; }
    .login-card { margin: 16px; padding: 32px 24px; }
    .detail-list { grid-template-columns: 1fr; }
    .detail-list dt { margin-top: 12px; }
    .form-actions { flex-direction: column; }
    .form-actions .btn-primary,
    .form-actions .btn-ghost { width: 100%; justify-content: center; }
}

/* =============================================
   BOTÓN DANGER (eliminar)
   ============================================= */
.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: transparent;
    color: #DC2626;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: .875rem;
    border: 2px solid #FCA5A5;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-danger:hover { background: #FEE2E2; border-color: #DC2626; }

.btn-warning {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: transparent;
    color: #D97706;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: .875rem;
    border: 2px solid #FCD34D;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-warning:hover { background: #FEF3C7; border-color: #D97706; }

/* =============================================
   ALERTA INFO
   ============================================= */
.alert-info { background: #DBEAFE; border-left: 4px solid #3B82F6; color: #1E40AF; }
.alert-warning { background: #FEF3C7; border-left: 4px solid #F59E0B; color: #92400E; }

/* =============================================
   TABLA / BADGE admin
   ============================================= */
.badge-admin { background: #EDE9FE; color: #5B21B6; }
.badge-operador { background: #F0FDF4; color: #166534; }
.badge-activo { background: #D1FAE5; color: #065F46; }
.badge-inactivo { background: #FEE2E2; color: #991B1B; }

/* =============================================
   IMPRESIÓN (Ctrl+P / botón imprimir ficha)
   ============================================= */
@media print {
    .topnav,
    .header-actions,
    .btn-primary,
    .btn-ghost,
    .btn-danger,
    .btn-warning,
    .btn-link,
    .btn-print,
    .no-print {
        display: none !important;
    }
    body {
        background: #fff;
        font-size: 12pt;
        color: #000;
    }
    .main-content { padding: 0; max-width: 100%; }
    .section-card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
        margin-bottom: 12pt;
        padding: 16pt;
    }
    .detail-grid { grid-template-columns: 1fr 1fr; gap: 12pt; }
    .formula-pre { font-size: 10pt; }
    .print-header {
        display: flex !important;
        align-items: center;
        gap: 16pt;
        margin-bottom: 20pt;
        border-bottom: 2pt solid #BE2026;
        padding-bottom: 12pt;
    }
    .print-header h1 { font-size: 18pt; }
    .print-header .print-logo { font-weight: 800; color: #BE2026; font-size: 14pt; }
}
.print-header { display: none; }

.btn-print {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: transparent;
    color: #374151;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: .875rem;
    border: 2px solid var(--gray-light);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-print:hover { background: var(--light); border-color: #9CA3AF; }

/* =============================================
   FONDO GENERAL — gradiente sutil
   ============================================= */
body {
    background: linear-gradient(160deg, #EEF1F8 0%, #F7F8FA 45%, #F0F4FF 100%);
    background-attachment: fixed;
}

/* =============================================
   NAV — display flex para íconos SVG
   ============================================= */
.topnav-links a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.topnav-links a svg { opacity: .75; flex-shrink: 0; }
.topnav-links a:hover svg,
.topnav-links a.active svg { opacity: 1; }
/* Indicador activo con subrayado animado */
.topnav-links a.active {
    position: relative;
}
.topnav-links a.active::after {
    content: '';
    position: absolute;
    bottom: 2px; left: 12px; right: 12px;
    height: 2px;
    background: var(--red);
    border-radius: 2px;
    animation: fadeIn .2s ease;
}

/* =============================================
   STAT CARD — íconos SVG modernos
   ============================================= */
.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px; height: 52px;
    border-radius: 14px;
    flex-shrink: 0;
    background: rgba(190,32,38,.1);
    color: var(--red);
}
.stats-row .stat-card:nth-child(1) .stat-icon { background: rgba(59,130,246,.12); color: #2563EB; }
.stats-row .stat-card:nth-child(1) { border-left-color: #2563EB; }
.stats-row .stat-card:nth-child(2) .stat-icon { background: rgba(190,32,38,.12); color: var(--red); }
.stats-row .stat-card:nth-child(2) { border-left-color: var(--red); }
.stats-row .stat-card:nth-child(3) .stat-icon { background: rgba(16,185,129,.12); color: #059669; }
.stats-row .stat-card:nth-child(3) { border-left-color: #059669; }
.stats-row .stat-card:nth-child(4) .stat-icon { background: rgba(245,158,11,.12); color: #D97706; }
.stats-row .stat-card:nth-child(4) { border-left-color: #D97706; }

/* =============================================
   ANIMACIONES DE ENTRADA
   ============================================= */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes rippleAnim {
    from { transform: scale(0); opacity: .45; }
    to   { transform: scale(2.8); opacity: 0; }
}
@keyframes trFadeIn {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes selectHighlightAnim {
    0%   { box-shadow: 0 0 0 3px rgba(16,185,129,.5); border-color: #10B981; }
    100% { box-shadow: none; border-color: var(--gray-light); }
}

.section-card  { animation: fadeSlideIn .32s ease both; }
.section-card:nth-child(1) { animation-delay: .00s; }
.section-card:nth-child(2) { animation-delay: .06s; }
.section-card:nth-child(3) { animation-delay: .12s; }
.section-card:nth-child(4) { animation-delay: .18s; }

.stat-card { animation: fadeSlideIn .32s ease both; }
.stats-row .stat-card:nth-child(1) { animation-delay: .00s; }
.stats-row .stat-card:nth-child(2) { animation-delay: .08s; }
.stats-row .stat-card:nth-child(3) { animation-delay: .16s; }
.stats-row .stat-card:nth-child(4) { animation-delay: .24s; }

tr.tr-animate {
    opacity: 0;
    animation: trFadeIn .22s ease both;
}

@media (prefers-reduced-motion: reduce) {
    .section-card, .stat-card, tr.tr-animate {
        animation: none !important;
        opacity: 1 !important;
    }
}

/* =============================================
   RIPPLE
   ============================================= */
.btn-primary, .btn-ghost, .btn-danger, .btn-warning, .btn-print {
    position: relative;
    overflow: hidden;
}
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,.38);
    pointer-events: none;
    animation: rippleAnim .55s ease-out forwards;
    transform-origin: center;
}
.btn-ghost   .ripple,
.btn-danger  .ripple,
.btn-warning .ripple,
.btn-print   .ripple { background: rgba(0,0,0,.09); }

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
.toast-container {
    position: fixed;
    top: 74px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--white);
    border-radius: 12px;
    padding: 13px 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.16);
    font-size: .875rem;
    font-weight: 500;
    min-width: 260px;
    max-width: 380px;
    pointer-events: all;
    opacity: 0;
    transform: translateX(48px);
    transition: opacity .28s ease, transform .28s ease;
    border-left: 4px solid var(--gray-light);
}
.toast.toast-show    { opacity: 1; transform: translateX(0); }
.toast-success       { border-left-color: #10B981; }
.toast-success .toast-icon { color: #10B981; }
.toast-error         { border-left-color: #EF4444; }
.toast-error   .toast-icon { color: #EF4444; }
.toast-info          { border-left-color: #3B82F6; }
.toast-info    .toast-icon { color: #3B82F6; }
.toast-msg   { flex: 1; color: var(--text); }
.toast-icon  { display: flex; flex-shrink: 0; }
.toast-close {
    background: none; border: none; cursor: pointer;
    color: var(--gray); font-size: 1.1rem; padding: 0 2px;
    line-height: 1; transition: color .15s;
}
.toast-close:hover { color: var(--dark); }

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,20,40,.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
    backdrop-filter: blur(3px);
    padding: 20px;
}
.modal-overlay.modal-open {
    opacity: 1;
    pointer-events: all;
}
.modal-card {
    background: var(--white);
    border-radius: 18px;
    padding: 32px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 24px 64px rgba(0,0,0,.22);
    transform: scale(.93) translateY(16px);
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
    opacity: 0;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-overlay.modal-open .modal-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--dark); }
.modal-close-btn {
    background: none; border: none; cursor: pointer;
    color: var(--gray); padding: 6px; border-radius: 8px;
    transition: all .15s; display: flex; align-items: center;
}
.modal-close-btn:hover { background: var(--light); color: var(--dark); }
.modal-error {
    background: #FEE2E2;
    border-left: 4px solid #EF4444;
    color: #991B1B;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: .85rem;
    margin-bottom: 16px;
    display: none;
}

/* =============================================
   SELECT CON BOTÓN INLINE (+ Nuevo cliente)
   ============================================= */
.select-with-btn {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.select-with-btn select { flex: 1; }
.btn-add-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 16px;
    background: var(--dark);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.btn-add-inline:hover { background: var(--red); }
.btn-add-inline .ripple { background: rgba(255,255,255,.3); }

/* =============================================
   SELECT HIGHLIGHT (cuando se agrega cliente)
   ============================================= */
.select-highlight {
    animation: selectHighlightAnim 1.4s ease forwards;
}

/* =============================================
   FORM GROUP FOCUSED
   ============================================= */
.form-group.focused > label { color: var(--red); transition: color .2s; }

/* =============================================
   PAGE HEADER mejorado
   ============================================= */
.page-header h1 {
    background: linear-gradient(135deg, var(--dark) 0%, #3B4A6B 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =============================================
   SECTION CARD — hover sutil
   ============================================= */
.section-card {
    transition: box-shadow .2s ease;
}
.section-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,.09);
}

/* =============================================
   BOTONES ICONO — acción en tablas
   ============================================= */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: all var(--transition);
    font-size: .875rem;
    color: var(--gray);
    text-decoration: none;
    flex-shrink: 0;
    line-height: 1;
    font-family: inherit;
    padding: 0;
}
.btn-icon:hover { background: var(--light); border-color: var(--gray-light); color: var(--dark); }
.btn-icon-view       { color: #2563EB; }
.btn-icon-view:hover { background: #EFF6FF; border-color: #BFDBFE; color: #1D4ED8; }
.btn-icon-edit       { color: #D97706; }
.btn-icon-edit:hover { background: #FEF3C7; border-color: #FCD34D; color: #B45309; }
.btn-icon-del        { color: #DC2626; }
.btn-icon-del:hover  { background: #FEE2E2; border-color: #FCA5A5; color: #B91C1C; }
.btn-icon-ok         { color: #059669; }
.btn-icon-ok:hover   { background: #D1FAE5; border-color: #6EE7B7; color: #047857; }
.table-actions { display: flex; gap: 4px; align-items: center; }

/* =============================================
   PAGINACIÓN — prev/next + ellipsis
   ============================================= */
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px; height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--gray-light);
    font-size: .875rem;
    font-weight: 500;
    transition: all var(--transition);
    color: var(--text);
    white-space: nowrap;
    text-decoration: none;
}
.page-link:hover { border-color: var(--red); color: var(--red); }
.page-link.active { background: var(--red); border-color: var(--red); color: var(--white); }
.page-ellipsis {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 6px;
    color: var(--gray);
    font-size: .875rem;
    user-select: none;
}

/* =============================================
   SELECCIÓN MASIVA — bulk toolbar
   ============================================= */
.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: .875rem;
    color: #1E40AF;
    flex-wrap: wrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.bulk-toolbar.visible { opacity: 1; pointer-events: all; }
.bulk-count { font-weight: 700; }
.bulk-sep { color: #BFDBFE; }
input.row-check,
input.check-all {
    width: 16px; height: 16px;
    cursor: pointer;
    accent-color: var(--red);
    flex-shrink: 0;
}
th.check-col, td.check-col {
    width: 42px;
    padding-left: 14px !important;
    padding-right: 4px !important;
}

/* =============================================
   TABLAS RESPONSIVE — card view en móvil
   ============================================= */
@media (max-width: 700px) {
    .data-table.table-cards { display: block; }
    .data-table.table-cards thead { display: none; }
    .data-table.table-cards tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .data-table.table-cards tr {
        display: block;
        background: var(--white);
        border-radius: var(--radius);
        border: 1px solid var(--gray-light);
        padding: 14px 16px;
        box-shadow: var(--shadow);
    }
    .data-table.table-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: 1px solid var(--gray-light);
        font-size: .875rem;
        border-radius: 0;
    }
    .data-table.table-cards td:last-child { border-bottom: none; padding-bottom: 0; }
    .data-table.table-cards td:first-child { padding-top: 0; }
    .data-table.table-cards td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: .72rem;
        color: var(--text-soft);
        text-transform: uppercase;
        letter-spacing: .06em;
        flex-shrink: 0;
        margin-right: 12px;
    }
    .data-table.table-cards td[data-label='']::before { display: none; }
    .data-table.table-cards td[data-label=''] { justify-content: flex-end; }
    .data-table.table-cards td.check-col { display: none; }
    .bulk-toolbar { display: none !important; }
}
/* overflow-x en pantallas medias */
@media (max-width: 900px) and (min-width: 701px) {
    .section-card { overflow-x: auto; }
}

/* =============================================
   SKIP LINK — accesibilidad
   ============================================= */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    z-index: 9999;
    background: var(--red);
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: .875rem;
    transition: top .15s ease;
    text-decoration: none;
}
.skip-link:focus { top: 8px; }

/* =============================================
   FOCUS VISIBLE — outline accesible
   ============================================= */
*:focus { outline: none; }
*:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
    border-radius: 4px;
}
.topnav *:focus-visible { outline-color: rgba(255,255,255,.8); }

/* =============================================
   DARK MODE TOGGLE BUTTON
   ============================================= */
.btn-dark-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,.18);
    color: rgba(255,255,255,.6);
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .875rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition);
}
.btn-dark-toggle:hover { color: var(--white); border-color: rgba(255,255,255,.45); }

/* =============================================
   DARK MODE — variables y overrides
   ============================================= */
html.dark {
    --white:      #1E1E2E;
    --light:      #13131F;
    --gray-light: #2D2D45;
    --text:       #E2E4EC;
    --text-soft:  #9CA3AF;
    --dark:       #F1F2F6;
    --shadow:     0 2px 12px rgba(0,0,0,.45);
    --shadow-md:  0 4px 24px rgba(0,0,0,.6);
}
html.dark body {
    background: linear-gradient(160deg, #0A0A14 0%, #12121E 50%, #0E0818 100%);
}
html.dark .topnav   { background: #080810; box-shadow: 0 2px 12px rgba(0,0,0,.5); }
html.dark .topnav-links a:hover { background: rgba(255,255,255,.07); }
html.dark .topnav-links a.active { background: rgba(255,255,255,.08); }
html.dark code {
    background: #2D2D45;
    color: #A5B4FC;
    border-color: #3D3D5A;
}
html.dark .badge-activo   { background: #064E3B; color: #6EE7B7; }
html.dark .badge-inactivo { background: #450A0A; color: #FCA5A5; }
html.dark .badge-admin    { background: #1E1B4B; color: #A5B4FC; }
html.dark .badge-operador { background: #1C2A1C; color: #86EFAC; }
html.dark .modal-overlay  { background: rgba(0,0,0,.75); }
html.dark .modal-card     { background: #1E1E2E; border: 1px solid var(--gray-light); }
html.dark .bulk-toolbar   { background: #1E2A3A; border-color: #2D3F5A; color: #93C5FD; }
html.dark .page-header h1 {
    background: linear-gradient(135deg, #E2E4EC 0%, #A5B4FC 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
html.dark .toast {
    background: #1E1E2E;
    border-left-color: var(--gray-light);
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
html.dark .toast-msg { color: var(--text); }
html.dark .alert-success { background: #064E3B; border-color: #059669; color: #6EE7B7; }
html.dark .alert-error   { background: #450A0A; border-color: #DC2626; color: #FCA5A5; }

/* =============================================
   TOM SELECT — ajuste de diseño
   ============================================= */
.ts-wrapper .ts-control {
    border-color: var(--gray-light);
    border-radius: 8px;
    background: var(--white);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: .875rem;
    padding: 8px 12px;
    min-height: 42px;
    box-shadow: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.ts-wrapper.focus .ts-control {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(190,32,38,.15);
    outline: none;
}
.ts-dropdown {
    border-color: var(--gray-light);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: .875rem;
    margin-top: 4px;
}
.ts-dropdown .option:hover,
.ts-dropdown .option.active { background: rgba(190,32,38,.08); color: var(--red); }
.ts-dropdown .option.selected { background: var(--red); color: var(--white); }
html.dark .ts-wrapper .ts-control { background: #1E1E2E; color: var(--text); }
html.dark .ts-dropdown { background: #1E1E2E; border-color: var(--gray-light); color: var(--text); }
html.dark .ts-dropdown .option:hover,
html.dark .ts-dropdown .option.active { background: rgba(190,32,38,.2); }
/* Compatibilidad con .select-with-btn + TomSelect */
.select-with-btn .ts-wrapper { flex: 1; }

/* =============================================
   FLATPICKR — ajuste de diseño
   ============================================= */
.flatpickr-input {
    font-family: 'Inter', system-ui, sans-serif !important;
}
.flatpickr-calendar {
    font-family: 'Inter', system-ui, sans-serif;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-light);
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: var(--red);
    border-color: var(--red);
}
.flatpickr-day:hover { background: rgba(190,32,38,.08); border-color: transparent; }
.flatpickr-months .flatpickr-month { color: var(--dark); }
html.dark .flatpickr-calendar {
    background: #1E1E2E;
    border-color: var(--gray-light);
    color: var(--text);
}
html.dark .flatpickr-day { color: var(--text); }
html.dark .flatpickr-day.flatpickr-disabled { color: var(--gray); }
html.dark .flatpickr-months .flatpickr-month,
html.dark .flatpickr-current-month,
html.dark .flatpickr-weekday { color: var(--text); background: #1E1E2E; fill: var(--text); }

/* =============================================
   CHARTS — contenedores dashboard
   ============================================= */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}
.chart-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-light);
}
.chart-card h3 {
    font-size: .9rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 18px;
}
.chart-wrap { position: relative; height: 220px; }
@media (max-width: 700px) {
    .charts-row { grid-template-columns: 1fr; }
    .chart-wrap { height: 180px; }
}
html.dark .chart-card { background: var(--white); border-color: var(--gray-light); }

