/* css/modules/cuadratura.css */

.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; background: white; padding: 10px 16px; border-radius: 8px; border: 1px solid #e2e8f0; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.header-right { display: flex; align-items: center; gap: 10px; }
.header-title { display: flex; align-items: center; gap: 15px; }
.header-title h2 { font-size: 1.1rem; color: #0f172a; margin: 0; font-weight: 600; }



/* Controles de iconos (Derecha) */
.controls-icons { display: flex; gap: 10px; align-items: center; }
.btn-icon { padding: 8px; border-radius: 50%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;}

/* === RANGE PICKER === */
.range-picker-wrapper { display: flex; align-items: center; gap: 8px; }
.range-label { font-size: 0.72rem; font-weight: 600; color: #059669; background: #ecfdf5; border: 1px solid #6ee7b7; border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.range-label.hidden { display: none; }

/* === ESTILOS DEL DATEPICKER DESPLEGABLE === */
.filter-group { display: flex; align-items: center; gap: 10px; font-size: 0.75rem; color: #64748b;}
.date-picker-dropdown { position: relative; }
.date-picker-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 240px;
}
.date-picker-menu.hidden { display: none; }
.date-inputs { display: flex; flex-direction: column; gap: 8px; }
.date-inputs label { display: flex; justify-content: space-between; align-items: center; font-weight: 500;}
.date-inputs input { padding: 6px 8px; border: 1px solid #cbd5e0; border-radius: 4px; font-family: inherit; color: #0f172a; outline: none; transition: border-color 0.2s; font-size: 0.75rem; width: 130px;}
.date-inputs input:focus { border-color: #4299e1; }
.btn-search-dates { width: 100%; justify-content: center; margin-top: 5px;}

/* === LAYOUT GRID DE TABLAS INFERIORES === */
.section-title { margin: 15px 0 8px 0; color: #0f172a; font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.5px; }
.bottom-tables-grid { display: flex; flex-direction: column; gap: 20px; margin-top: 15px; }
@media(min-width: 1024px) {
    .bottom-tables-grid { flex-direction: row; align-items: flex-start; }
    .table-section { flex: 1; min-width: 0; }
}

.card { background: white; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); border: 1px solid #e2e8f0; overflow-x: auto; z-index: 1;}

/* --- TABLA CORPORATIVA FIJA --- */
.sheet-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 0.75rem; text-align: right; color: #64748b; table-layout: fixed; }
.sheet-table th, .sheet-table td { padding: 5px 4px; border: 1px solid #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* DIETA ESTRICTA DE PIXELES */
.col-check, .td-check { width: 30px !important; text-align: center; }
.col-fecha, .td-fecha { width: 70px !important; text-align: center;}
.col-notas, .td-notas { width: 34px !important; text-align: center; }
.col-com-porc, .td-com { width: 45px !important; text-align: center;}
.col-com-monto, .td-com-monto { width: 64px !important; }
.col-ahorro, .td-ahorro { width: 62px !important; }

.col-generic { width: 64px !important; }
.col-global, .col-pago, .col-sii { width: 64px !important; }

/* =============================================
   HEADERS — grupos principales
   ============================================= */
.header-group th {
    color: #fff;
    padding: 6px 4px;
    text-align: center;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    font-size: 0.65rem;
    line-height: 1.3;
    position: relative;
    z-index: 10;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.col-check  { background: #1e293b; }
.col-fecha  { background: #0f172a; }
.col-global { background: #059669; }
.col-pago   { background: #ea580c; }
.col-com    { background: #dc2626; }
.col-bazar  { background: #2563eb; }
.col-caf    { background: #7c3aed; }
.col-sii    { background: #0d9488; }
.col-guardar{ background: #475569; }
.col-trans  { background: #16a34a; }
.col-notas  { background: #1e293b; }
.col-iva-prov { background: #0891b2; }

/* =============================================
   SUBHEADERS — fila secundaria
   ============================================= */
.header-sub th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 700;
    font-size: 0.63rem;
    letter-spacing: 0.3px;
    border-bottom: 2px solid #e2e8f0;
    text-align: center;
    position: relative;
    z-index: 10;
    text-transform: uppercase;
    padding: 5px 4px;
}

.th-bazar-sub    { background: #2563eb !important; color: #fff !important; text-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.th-caf-sub      { background: #7c3aed !important; color: #fff !important; text-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.th-prov-sub     { background: #475569 !important; color: #fff !important; text-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.th-liq-sub      { background: #16a34a !important; color: #fff !important; text-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.th-iva-prov-sub { background: #0891b2 !important; color: #fff !important; text-shadow: 0 1px 2px rgba(0,0,0,0.15); }

/* V.TARJ-COM resaltado en las 3 tablas */
.th-vtarj { background: #ea580c !important; color: #fff !important; text-shadow: 0 1px 2px rgba(0,0,0,0.2); font-weight: 800 !important; }
.td-vtarj { color: #9a3412 !important; font-weight: 700 !important; background: #fff7ed !important; }

/* =============================================
   CELDAS DE DATOS
   ============================================= */
.sheet-table tbody tr { transition: background 0.15s; }
.sheet-table tbody tr:hover td:not(.td-notas) { box-shadow: inset 0 0 0 9999px rgba(99, 179, 237, 0.12); }

.td-fecha { position: sticky; left: 0; z-index: 20; background: #f8fafc; font-weight: 700; border-right: 2px solid #cbd5e0 !important; color: #0f172a; letter-spacing: 0.2px; }

.td-total-main { font-weight: 700; background: #f0fff4; color: #22543d; }

.td-pago { color: #9a3412; background: #fff7ed; font-weight: 700; }

.td-com       { font-weight: 700; color: #9b2c2c; background: #fff5f5; }
.td-com-monto { font-weight: 700; color: #9b2c2c; background: #fff5f5; }

.td-iva { background: #f8fafc; font-weight: 700; color: #1e293b; }

.td-exento   { color: #22543d; background: #f0fff4; font-weight: 700; }
.td-propinas { color: #1e3a5f; background: #eff6ff; font-weight: 700; }

.td-subtotal { font-weight: 600; color: #0f172a; }
.td-neto     { font-weight: 600; color: #0f172a; }

.td-iva-prov   { color: #164e63; font-weight: 800; background: #ecfeff; }
.td-iva-detail { color: #64748b; font-weight: 600; background: #f8fafc; }

.td-final-bazar, .td-final-caf {
    background: #f0fdf4;
    color: #166534;
    font-weight: 800;
    font-size: 0.78rem;
}

/* =============================================
   EDITABLES — NOTA POPOVER
   ============================================= */
.nota-wrapper { display: flex; align-items: center; justify-content: center; position: relative; }

.nota-btn { padding: 0; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border: 1px solid #e2e8f0; cursor: pointer; transition: all 0.2s; }
.nota-btn--has { background: #ecfdf5; border-color: #6ee7b7; color: #059669; }
.nota-btn--empty { background: #f8fafc; border-color: #e2e8f0; color: #cbd5e0; }
.nota-btn:hover { transform: scale(1.15); box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
.nota-btn--has:hover { background: #d1fae5; }

.nota-popover.hidden, .nota-tooltip.hidden { display: none; }
.nota-tooltip { position: fixed; background: #0f172a; color: #fff; font-size: 0.7rem; padding: 7px 10px; border-radius: 6px; white-space: pre-wrap; max-width: 200px; min-width: 80px; text-align: left; z-index: 9998; box-shadow: 0 4px 12px rgba(0,0,0,0.25); line-height: 1.5; pointer-events: none; }

.nota-popover { position: fixed; background: white; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 9999; width: 200px; }

.nota-textarea { width: 100%; min-height: 70px; font-size: 0.72rem; font-family: inherit; border: 1px solid #e2e8f0; border-radius: 6px; padding: 6px 8px; outline: none; resize: vertical; color: #0f172a; line-height: 1.5; transition: border-color 0.2s; }
.nota-textarea:focus { border-color: #10b981; box-shadow: 0 0 0 3px rgba(66,153,225,0.15); }

.nota-popover-hint { font-size: 0.62rem; color: #94a3b8; text-align: right; margin-top: 5px; }

.input-nota { width: 100%; font-size: 0.65rem; border: 1px solid #4299e1; border-radius: 4px; padding: 2px 4px; outline: none; font-family: inherit;}

.ahorro-wrapper { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.ahorro-val { color: #64748b; font-weight: 600; transition: color 0.2s; font-size: 0.72rem; }

.ahorro-btn { background: none; border: none; padding: 1px 2px; cursor: pointer; color: #94a3b8; border-radius: 3px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.ahorro-btn:hover { background: #ede9fe; color: #6d28d9; }


/* =============================================
   CHECKBOX
   ============================================= */
.custom-checkbox { display: block; position: relative; cursor: pointer; user-select: none; height: 14px; width: 14px; margin: 0 auto; }
.custom-checkbox input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }
.checkmark { position: absolute; top: 0; left: 0; height: 14px; width: 14px; background-color: #f1f5f9; border: 1px solid #cbd5e0; border-radius: 3px; transition: all 0.2s;}
.custom-checkbox:hover input ~ .checkmark { background-color: #e2e8f0; }
.custom-checkbox input:checked ~ .checkmark { background-color: #10b981; border-color: #059669; box-shadow: 0 0 0 2px rgba(16,185,129,0.2); }
.checkmark:after { content: ""; position: absolute; display: none; }
.custom-checkbox input:checked ~ .checkmark:after { display: block; }
.custom-checkbox .checkmark:after { left: 4px; top: 1px; width: 3px; height: 8px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* =============================================
   FILAS ESPECIALES
   ============================================= */
.row-paid { opacity: 0.45; background-color: #f8fafc !important; transition: opacity 0.3s; }
.row-paid:hover { opacity: 0.75; }

.row-totals { background: #e8f4fd; color: #0f172a; }
.row-totals td {
    border-top: 2px solid #94a3b8 !important;
    border-bottom: 2px solid #94a3b8 !important;
    padding-top: 8px;
    padding-bottom: 8px;
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.2px;
}

/* =============================================
   ESTADO DE CUENTA — DEUDAS CAFETERÍA
   ============================================= */
.deudas-card { padding: 0; overflow: visible !important; }

.deudas-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; gap: 8px; }
.deudas-title-row { display: flex; align-items: center; gap: 10px; }
.deudas-title { font-size: 0.78rem; font-weight: 700; color: #0f172a; text-transform: uppercase; letter-spacing: 0.4px; }
.deudas-saldo-badge { font-size: 0.8rem; font-weight: 800; padding: 3px 10px; border-radius: 20px; }
.deudas-saldo-badge.deuda-monto-neg { background: #fff5f5; color: #c53030; border: 1px solid #feb2b2; }
.deudas-saldo-badge.deuda-monto-pos { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }

.deudas-actions { display: flex; gap: 8px; }
.btn-deuda-add { display: flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 6px; font-size: 0.72rem; font-weight: 600; border: none; cursor: pointer; font-family: inherit; transition: all 0.2s; }
.btn-deuda-adelanto { background: #fff5f5; color: #c53030; border: 1px solid #feb2b2; }
.btn-deuda-adelanto:hover { background: #fed7d7; }
.btn-deuda-pago { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }
.btn-deuda-pago:hover { background: #c6f6d5; }

.deuda-form { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; border-left: 3px solid #e53e3e; flex-wrap: wrap; }
.deuda-form.hidden { display: none; }
.deuda-input { padding: 5px 8px; border: 1px solid #cbd5e0; border-radius: 5px; font-size: 0.75rem; font-family: inherit; color: #0f172a; outline: none; transition: border-color 0.2s; }
.deuda-input:focus { border-color: #4299e1; }
.deuda-input-desc { flex: 1; min-width: 120px; }
.btn-deuda-guardar { background: #0f172a; color: white; border: none; border-radius: 5px; padding: 5px 12px; font-size: 0.72rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-deuda-guardar:hover { background: #1e293b; }
.btn-deuda-cancelar { background: none; border: none; color: #94a3b8; font-size: 0.85rem; cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.btn-deuda-cancelar:hover { color: #e53e3e; background: #fff5f5; }

.deuda-table { width: 100%; border-collapse: collapse; font-size: 0.72rem; }
.deuda-thead th { background: #f8fafc; color: #64748b; font-weight: 700; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.3px; padding: 6px 10px; border-bottom: 1px solid #e2e8f0; text-align: left; }
.deuda-row:hover { background: #f8fafc; }
.deuda-td { padding: 7px 10px; border-bottom: 1px solid #f8fafc; color: #64748b; vertical-align: middle; }
.deuda-fecha { font-weight: 600; color: #0f172a; white-space: nowrap; }
.deuda-num { font-weight: 700; text-align: right; white-space: nowrap; }
.deuda-saldo { font-weight: 700; text-align: right; white-space: nowrap; }
.deuda-desc { color: #64748b; font-size: 0.68rem; }
.deuda-del { text-align: center; width: 30px; }

.deuda-badge-adelanto { color: #c53030; font-weight: 700; }
.deuda-badge-pago { color: #276749; font-weight: 700; }
.deuda-monto-neg { color: #c53030; }
.deuda-monto-pos { color: #276749; }

.btn-deuda-del { background: none; border: none; color: #cbd5e0; cursor: pointer; padding: 3px; border-radius: 4px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.btn-deuda-del:hover { color: #e53e3e; background: #fff5f5; }

.deuda-empty { padding: 20px; text-align: center; color: #94a3b8; font-size: 0.78rem; }

/* =============================================
   CIERRE DE PERÍODO — CAFETERÍA
   ============================================= */
.row-cierre td { padding: 6px 5px; border-top: 1px solid #e2e8f0; font-size: 0.75rem; }
.row-cierre:first-of-type td { border-top: 2px solid #94a3b8; }
.cierre-label { text-align: right; font-weight: 600; color: #64748b; padding-right: 8px; }
.cierre-saldo-val { text-align: right; font-weight: 800; font-size: 0.75rem; padding-right: 5px; }
.cierre-deuda-val { text-align: right; font-weight: 800; font-size: 0.75rem; padding-right: 5px; }
.cierre-input { width: 90px; padding: 4px 6px; border: 1px solid #cbd5e0; border-radius: 5px; font-size: 0.72rem; font-family: inherit; text-align: right; outline: none; transition: border-color 0.2s; }
.cierre-input:focus { border-color: #4299e1; box-shadow: 0 0 0 2px rgba(66,153,225,0.15); }
.cierre-liq-input { border-color: #9ae6b4; }
.cierre-liq-input:focus { border-color: #38a169; box-shadow: 0 0 0 2px rgba(56,161,105,0.15); }
.row-cierre-btn td { border-top: 1px solid #e2e8f0; background: #f8fafc; }
.btn-cerrar-periodo { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; background: #16a34a; color: white; border: none; border-radius: 6px; font-size: 0.75rem; font-weight: 700; cursor: pointer; font-family: inherit; transition: background 0.2s; }
.btn-cerrar-periodo:hover { background: #15803d; }

/* =============================================
   MODAL CONFIRMACIÓN CIERRE DE PERÍODO
   ============================================= */
.modal-cierre-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99999; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal-cierre-box { background: white; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); width: 340px; overflow: hidden; }
.modal-cierre-header { background: #0f172a; color: white; padding: 14px 18px; font-size: 0.85rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-cierre-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.modal-cierre-periodo { font-size: 0.7rem; color: #64748b; background: #f8fafc; border-radius: 6px; padding: 6px 10px; font-weight: 600; margin-bottom: 4px; }
.modal-cierre-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: #64748b; padding: 2px 0; }
.modal-cierre-row .modal-val { font-weight: 700; }
.modal-neg .modal-val { color: #c53030; }
.modal-pos .modal-val { color: #276749; }
.modal-highlight { background: #f0fff4; border-radius: 6px; padding: 8px 10px; margin: 4px -4px; }
.modal-highlight .modal-val { color: #276749; font-size: 0.9rem; }
.modal-cierre-divider { height: 1px; background: #e2e8f0; margin: 4px 0; }
.modal-cierre-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; background: transparent; }
.modal-btn-cancelar { background: #f1f5f9; color: #64748b; border: none; border-radius: 6px; padding: 7px 14px; font-size: 0.75rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.modal-btn-cancelar:hover { background: #e2e8f0; }
.modal-btn-confirmar { background: #16a34a; color: white; border: none; border-radius: 6px; padding: 7px 14px; font-size: 0.75rem; font-weight: 700; cursor: pointer; font-family: inherit; display: flex; align-items: center; gap: 6px; }
.modal-btn-confirmar:hover { background: #15803d; }

/* =============================================
   RANGE CALENDAR
   ============================================= */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-month { font-size: 0.8rem; font-weight: 700; color: #0f172a; }
.cal-nav { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: #64748b; padding: 2px 6px; border-radius: 4px; line-height: 1; }
.cal-nav:hover { background: #f1f5f9; color: #0f172a; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.cal-weekdays div { text-align: center; font-size: 0.6rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; padding: 2px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day { text-align: center; font-size: 0.72rem; padding: 5px 2px; border-radius: 5px; cursor: pointer; color: #64748b; transition: all 0.15s; }
.cal-day:hover { background: #ecfdf5; color: #059669; }
.cal-selected { background: #10b981 !important; color: white !important; font-weight: 700; border-radius: 5px; }
.cal-in-range { background: #ecfdf5; color: #059669; border-radius: 0; }
.cal-range-info { text-align: center; font-size: 0.72rem; font-weight: 600; color: #059669; background: #ecfdf5; border-radius: 6px; padding: 4px 8px; margin-top: 6px; }
.cal-apply-btn { width: 100%; margin-top: 6px; background: #0f172a; color: white; border: none; border-radius: 6px; padding: 7px; font-size: 0.75rem; font-weight: 700; cursor: pointer; font-family: inherit; transition: background 0.2s; }
.cal-apply-btn:hover { background: #1e293b; }
.range-label-clear { margin-left: 4px; cursor: pointer; opacity: 0.6; font-size: 0.65rem; }
.range-label-clear:hover { opacity: 1; }
.th-exento-sub  { background: #059669 !important; color: #fff !important; text-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.th-propina-sub { background: #2563eb !important; color: #fff !important; text-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.row-totals td { font-weight: 800 !important; }

/* Validación cuadratura */
.td-check-validacion { width: 30px !important; text-align: center; vertical-align: middle; }
.validacion-ok, .validacion-err { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; cursor: help; }
.validacion-ok { background: #dcfce7; }
.validacion-err { background: #fee2e2; }
.btn-abono-todo { background: #ecfdf5; border: 1px solid #6ee7b7; color: #059669; border-radius: 4px; padding: 3px 5px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.btn-abono-todo:hover { background: #d1fae5; border-color: #10b981; }