:root {
    --primary-color: #4361ee;
    --bg-color: #f4f7fe;
    --text-color: #2b3674;
    --card-bg: #ffffff;
    --success: #05cd99;
    --danger: #ee5d50;
    --header-height: 60px;
    --sidebar-width: 260px;
    --border-color: #e0e5f2;
    --input-bg: #f8f9fc;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background-color: var(--bg-color); color: var(--text-color); min-height: 100vh; font-size: 14px; }
a { text-decoration: none; color: inherit; transition: .2s; }
ul { list-style: none; }
button { font: inherit; cursor: pointer; border: none; background: none;}
input, select, textarea { font-size: 14px; }

/* Header y Menú (Móvil) */
.mobile-header { background-color: var(--card-bg); height: var(--header-height); width: 100%; position: fixed; top: 0; left: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); z-index: 1000; }
.mobile-header h2 { color: var(--primary-color); font-size: 20px; }
.menu-toggle { display: flex; flex-direction: column; gap: 5px; padding: 5px; z-index: 1001; }
.menu-toggle span { display: block; width: 25px; height: 3px; background-color: var(--primary-color); border-radius: 3px; transition: 0.3s; }
.sidebar { background-color: var(--card-bg); position: fixed; top: var(--header-height); left: -100%; width: 260px; height: calc(100vh - var(--header-height)); padding: 20px; transition: 0.3s ease; box-shadow: 2px 0 10px rgba(0,0,0,0.05); z-index: 999; display: flex; flex-direction: column; }
.sidebar h2 { display: none; }
.sidebar.active { left: 0; }
.sidebar-overlay { position: fixed; top: var(--header-height); left: 0; width: 100%; height: 100vh; background: rgba(0,0,0,0.5); display: none; z-index: 998; }
.sidebar-overlay.active { display: block; }
.sidebar a { display: block; padding: 12px 15px; margin-bottom: 5px; border-radius: 8px; font-weight: 600; color: #a3aed1; }
.sidebar a:hover, .sidebar a.active { background-color: var(--primary-color); color: white; }

.main-content { padding: 15px; padding-top: calc(var(--header-height) + 15px); width: 100%; overflow-x: hidden; }
h1 { margin-bottom: 20px; font-size: 22px; }

/* Tarjetas y Formularios */
.card, .form-container { background-color: var(--card-bg); padding: 20px; border-radius: 15px; box-shadow: 0 4px 10px rgba(0,0,0,0.02); margin-bottom: 20px; width: 100%; }
.card-header, .form-header { margin-bottom: 15px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px;}
.card-header h3, .form-header h3 { font-size: 14px; color: #a3aed1; text-transform: uppercase; letter-spacing: 0.5px; margin: 0;}
.card .amount { font-size: 28px; font-weight: bold; color: var(--text-color); margin-bottom: 10px; }
.card .details { font-size: 12px; color: #666; display: flex; flex-direction: column; gap: 5px; }

.dashboard-cards { display: grid; grid-template-columns: 1fr; gap: 15px; margin-bottom: 20px; }
.grid-form-2cols { display: flex !important; flex-direction: column !important; gap: 12px !important; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-weight: 600; font-size: 12px; color: #666; }
.form-group input, .form-group select { padding: 12px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--input-bg); color: var(--text-color); width: 100%; }

/* Botones corregidos */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 12px; border-radius: 8px; font-weight: bold; font-size: 14px; color: white; background-color: var(--primary-color); width: 100%; transition: .2s; }
.btn-success { background-color: var(--success); }
.btn-danger { background-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 12px; width: auto; border-radius: 6px;}

/* Alertas */
.alert-warning { background: #fff3cd; color: #856404; padding: 12px; border-radius: 8px; font-size: 13px; margin-bottom: 15px;}
.alert-danger { background: #fee8e6; color: var(--danger); padding: 12px; border-radius: 8px; font-size: 13px; margin-bottom: 15px;}

/* ==========================================
   TABLAS COMPACTAS (Para ver de un vistazo)
   ========================================== */
.table-responsive { width: 100%; overflow-x: auto; border-radius: 10px; border: 1px solid var(--border-color); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--border-color); }
th { color: #a3aed1; text-transform: uppercase; font-size: 10px; background: #f8f9fc; font-weight: bold; white-space: nowrap;}
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background-color: #fbfcfe; }
.desc-cell { white-space: normal; min-width: 100px; line-height: 1.3; font-weight: 500;} /* Permite que el texto baje de línea */
.amount-cell { text-align: right; font-weight: bold; white-space: nowrap; }
.badge-user { padding: 3px 6px; border-radius: 10px; font-size: 10px; color: white; text-transform: uppercase; }

/* Utilidades de texto */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: #a3aed1 !important; font-size: 10px; display: block;}

/* ==========================================
   FILTROS NUEVOS (Cuadrícula compacta)
   ========================================== */
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 15px; background: #f8f9fc; padding: 10px; border-radius: 10px; border: 1px solid var(--border-color); }
.filter-grid input, .filter-grid select { padding: 10px; border: 1px solid #e0e5f2; border-radius: 6px; font-size: 13px; background: white; width: 100%; outline: none; }
.filter-grid input:focus, .filter-grid select:focus { border-color: var(--primary-color); }
.filter-grid .full-width { grid-column: 1 / -1; } /* Para que el buscador ocupe toda la fila arriba */

/* PC */
@media (min-width: 801px) {
    body { display: flex; font-size: 15px;}
    .mobile-header, .sidebar-overlay { display: none !important; }
    .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-width); height: 100vh; padding: 25px; border-right: 1px solid var(--border-color); }
    .sidebar h2 { display: block; color: var(--primary-color); margin-bottom: 30px; text-align: center; font-size: 22px;}
    .main-content { margin-left: var(--sidebar-width); padding: 30px; width: calc(100% - var(--sidebar-width)); padding-top: 30px;}
    .dashboard-cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
    .grid-form-2cols { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 15px !important; }
    .filter-grid { grid-template-columns: 2fr 1fr 1fr 1fr; } /* Filtros en línea en PC */
    .filter-grid .full-width { grid-column: auto; }
    table { font-size: 14px; }
    th, td { padding: 12px 10px; }
}

/* Ajustes para que los números del Gestor no se salgan */
.kpi-card-gestor { padding: 12px !important; }
.kpi-card-gestor h3 { font-size: 12px !important; margin-bottom: 5px !important; }
.kpi-card-gestor .amount { 
    font-size: clamp(16px, 4.5vw, 26px) !important; /* Se encoge automáticamente en pantallas pequeñas */
    word-wrap: break-word; 
}

/* Nuevo diseño para Cobros Vencidos en fijos.php */
.vencidos-card {
    background-color: #fffbfa;
    border-left: 5px solid var(--danger);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 25px;
    box-shadow: 0 4px 12px rgba(238, 93, 80, 0.15);
}
.vencidos-header {
    color: var(--danger);
    font-weight: 800;
    font-size: 15px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.vencido-item {
    background: white;
    border: 1px solid #fbdcda;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
}
.vencido-item:last-child { margin-bottom: 0; }